0

Does anyone know how to mask the input in a DateField in flex?

Our DateField uses the format DD/MM/YYYY.

Our users want:

  • to be able to type the date in without having to type in the slash
  • still be able to use the date selection in the date chooser (the drop down on the date field)

I google’d and found ways to do this with 3 text boxes. I would prefer to have a DateField control. That way the users would be able to make use of the date chooser (drop down) as well.

cp5
  • 1,087
  • 6
  • 26
  • 58
  • I had to write a custom component for this. Sorry, can't share - and it's Flex 4 anyway. Perhaps you can search for open-source components. – RIAstar Mar 12 '13 at 13:03
  • http://cookbooks.adobe.com/post_Simple_DateField_extension_with_masked_input-15666.html I found the following solution that looks good but I just cant seem to get the date from the control after I entered it. All of the below properties on the object seems to be null dfServiceDate.selectedDate, dfServiceDate.selectedDate, dfServiceDate.value, dfServiceDate.text, dfServiceDate.selectedItem – cp5 Mar 13 '13 at 07:18

2 Answers2

2

I would suggest adding a KeyboardEvent to the DateField, and handle the logic of adding or removing slashes inside the event listener function.

Sakthi Kumar
  • 3,047
  • 15
  • 28
0

I found the best way to do this is onFocusOut I take the text and add the slashes back and reset the formatted text, before any validation fires.

Full Code post to follow:

cp5
  • 1,087
  • 6
  • 26
  • 58