1

I am using an mx:DateField in Flex and it works nice with the date picker, but I also need it to be editable, so i set editable="true".

The problem is that now the user can enter anything they want - even though I have a formatString="YYYY-MM-DD" set. The date picker honors this format, but if the user enters in the format MM/DD/YYYY they can - or they can even enter garbage data.

I realize I can set up a data validator to check that it is a valid date and in the appropriate format as per the flex docs, but I was hoping to have something I have seen in other languages where the text field would show something like "0000-00-00" and the user clicks in to the field and it allows them to change only the digits (the zeros) and can not type any alpha characters or add/remove any length.

Any ideas?

2 Answers 2

0

Try to use masked text input for that.

4
  • This looks good and even includes source. The only thing left to make this perfect is a way to have the little DateField calendar icon and pop-up a date picker. Maybe that is a different component? May 15, 2011 at 20:56
  • You can place icon by yourself and pop up DateChooser on click. May 15, 2011 at 21:00
  • But That masked Test input control does't throw any value after date is selected or enter mean selelctedDate & text property are null and empty.I am using Flex 4.5
    – Tahir Alvi
    Nov 5, 2012 at 12:20
  • And above solution is not working when using Flash Player 10.3 or greater.
    – Tahir Alvi
    Nov 5, 2012 at 12:28
0

Personally, I wouldn't use a DateField. I would create a custom component that has 3 separate TextInputs, one for each year, month and day, and have a DateChooser on the right side if the user wants to pick the date manually.

You'll have to add logic to have the focus bounce from one textinput to the next. You can even make them look like they're in the same component with dashes in between. The user thinks it's just one component, but it's actually a composite component.

Anywho, just my 2 cents. I've done it before with good results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.