1 Reply Latest reply on Feb 13, 2007 4:19 PM by KomputerMan.com

    DateValidator

    KomputerMan.com Level 1
      Has anybody got the DateValidator to work when using a DD-MMM-YYYY format??? If so what did you do??? So far I have tried the following without success:
      <mx:DateValidator id="MyDepDOBValid" source="{Input_Dep_DOB}" property="text" />
      <mx:DateValidator id="MyDepDOBValid" source="{Input_Dep_DOB}" property="text" dayProperty="text" monthProperty="text" yearProperty="text" />
      <mx:DateValidator id="MyDepDOBValid" source="{Input_Dep_DOB}" property="text" inputFormat="DD-MMM-YYYY" />

      I call my validator prior to sending the object to the CF back end for processing just as an FYI.


      Sorry if this question has already been answered but the search utility ust isn't working right now and I need an answer. Thanks in advance for your help!!!

      Have an Ordinary Day...
      KomputerMan ~|:-)
        • 1. DateValidator
          KomputerMan.com Level 1
          O.K. so it wasn't the slickest way to do things but here is the work around I found. Turns out the DateValidator only works with MM/DD/YYYY, or in other words the month has to be a integer and can not be text. So with that in mind I created a little AS file called KDL_Library.as and put the following code in it:

          public function getKDLDate(tmpDate:String): String
          {
          var myDay:String = tmpDate.substring(0, 2);
          var myMon:String = tmpDate.substring(3, 6);
          var myYear:String = tmpDate.substring(7, 11);
          var tmpMonth:String;

          switch (myMon)
          {
          case "Jan":
          tmpMonth = "01";
          break;
          case "Feb":
          tmpMonth = "02";
          break;
          case "Mar":
          tmpMonth = "03";
          break;
          case "Apr":
          tmpMonth = "04";
          break;
          case "May":
          tmpMonth = "05";
          break;
          case "Jun":
          tmpMonth = "06";
          break;
          case "Jul":
          tmpMonth = "07";
          break;
          case "Aug":
          tmpMonth = "08";
          break;
          case "Sep":
          tmpMonth = "09";
          break;
          case "Oct":
          tmpMonth = "10";
          break;
          case "Nov":
          tmpMonth = "11";
          break;
          case "Dec":
          tmpMonth = "12";
          break;
          default:
          tmpMonth = "00"
          }

          var myDate:String = tmpMonth + "/" + myDay + "/" + myYear;

          return myDate;
          }

          Now I can call this snippet from any of my form validation pages like this:
          if (Input_Dep_DOB.text != "") // the field I want verified
          {
          var myDate:String = getKDLDate(Input_Dep_DOB.text);

          vResult = MyDepDOBValid.validate(myDate);
          if (vResult.type == ValidationResultEvent.INVALID)
          {
          x = 2; // insert your error trapping stuff here...
          }
          }

          And last but not least my DateValidator looks like this:
          <mx:DateValidator id="MyDepDOBValid" dayProperty="text" monthProperty="text" yearProperty="text" />

          I think there should be an easier way to do this but I couldn't find one. Oh well this works too...

          Have an Ordinary Day...
          KomputerMan ~|:-)