1 Reply Latest reply on Feb 25, 2010 8:59 AM by Gregory Lafrance

    Date Validation

    194642537

      Hi All,

       

       

           I want to validate whether the date entered is in dd-mm-yyyy format. I dont want to use built in validators.

      Can anybody pleaseshare a working code or a link to help me

       

      Thanks

        • 1. Re: Date Validation
          Gregory Lafrance Level 6

          This should answer your question:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                import mx.controls.Alert;
                private function checkInput():void{
                  if(txt.text.match(/\d\d-\d\d-\d\d\d\d/) != null){
                    mx.controls.Alert.show("Date format is correct.");
                  }else{
                    mx.controls.Alert.show("Date format is wrong.");
                  }
                }
              ]]>
            </mx:Script> 
            <mx:TextInput id="txt"/>
            <mx:Button label="Validate Input" click="checkInput();"/>
          </mx:Application>
          
          

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services