korymiller
korymiller

Reputation: 357

Formatting Date of Birth Text Input in Flex

I have a TextInput for a user to enter their Date of Birth. Right now they just enter a string of numbers and I parse it for the correct values but this can be very inefficient. What I am looking to do is have the TextInput automatically formatted to look --/--/---- so the user can click in it and fill in the '-' fields while leaving the '/' for formatting purposes. Does anyone know of a good way to do this?

Thanks in advance for any advice!

Upvotes: 1

Views: 964

Answers (2)

Constantiner
Constantiner

Reputation: 14221

You can use Adobe Masked TextInput for that.

Upvotes: 5

laurent
laurent

Reputation: 90873

If you try to do that with just one TextInput, it's going to be very complicated (if not impossible). To keep it simple, you could simply use three TextInputs and separate them with "/". Then simply style the TextInputs to make it look like there's only one text field.

Also you could add an event listener on the textChange event. That way you can validate the input as it's being typed and jump to the next field once you get a valid number.

Upvotes: 2

Related Questions