Use DateValidator to validate and use DateForamtter to format
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" minWidth="1024" minHeight="768">
<mx:DateFormatter id="dateFormatter" formatString="day: DD, month: MM, year: YYYY"/>
<mx:DateValidator id="dateVal" inputFormat="mm/dd/yyyy"/>
<mx:Script>
import mx.events.ValidationResultEvent;
private var vResult:ValidationResultEvent;
private function dateFormat():void
{
vResult = dateVal.validate(inputDate.text);
if (vResult.type==ValidationResultEvent.VALID) {
inputDate.text = dateFormatter.format(inputDate.text);
} else {
inputDate.text= "";
}
}
</mx:Script>
<mx:Label text="Date Input"/>
<mx:TextInput id="inputDate" focusOut="dateFormat();" width="300"/>
</mx:Application>
Related examples in the same category