开发者

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 l开发者_JS百科ooking 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!


You can use Adobe Masked TextInput for that.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜