1 Reply Latest reply: Jun 7, 2010 9:12 PM by Albert S. RSS

    Validate Form based on date greater than now but less than 14 days?

    jgr0h

      Does anyone know how to set up the ADDT form validation so that a person will have to enter a date greater than {NOW} but less than 14 days from now? I tried searching here but the search on this site stinks. And, I found some "similar" things on the interakt site but nothing worked for me. I am using PHP and my database format is YYYY-MM-DD. Any help is greatly appreciated!

       

      Thank you

      John

        • 1. Re: Validate Form based on date greater than now but less than 14 days?
          Albert S. Community Member

          Hi,

           

          So I been messing a little with your  idea in ADDT, and while I don't have a complete solution there is a way  if your good with regular expression and PHP.

           

          Here is a basic form validation  that ADDT offers (code view) using regex.

          The field name is  regDate which is then using a regular expression to make sure the dates  fall between 1-1-1900 - 31-12-2099.

          Given this doesnt work with  your NOW to 14days future date but this is just an idea/example.

           

          // Start  trigger
          $formValidation = new tNG_FormValidation();
          $formValidation->addField("regDate",  true, "regexp",  "(^((((0[1-9])|([1-2][0-9])|(3[0-1]))|([1-9]))\-(((0[1-9])|(1[0-2]))|([1-9]))\-  (([0-9]{2})|(((19)|([2]([0]{1})))([0-9]{2}))))$)", "", "", "");
          $tNGs->prepareValidation($formValidation);
          //  End trigger

           

          Now  if we took this concept and created a script that would read todays  date then calculated the 14days+ then writes a variable that contained  the regular expression for just those 14days. Then you can add something  like this...

           

          //My  Regular Expression Variable created from script.

          $myregexvalue =  '(\b10\-\b10-\b2009\)|(\b10\-\b24\-\b2009\)'

           

          // Start trigger
          $formValidation = new tNG_FormValidation();
          $formValidation->addField("regDate", true, "regexp", $myregexvalue,   "", "", "");
          $tNGs->prepareValidation($formValidation);
          //  End trigger

           

          The  key would obviously be to create a script that would find the dates  needed then created a tight regex for those specific dates.

          Well  that's my 2 cents on the matter.

           

          Happy Coding, if you come up with a solution  I would love to hear about it.