4 Replies Latest reply on Jun 7, 2010 9:13 PM by Albert S.

    Using DatePicker but can choose dates in past

    Joseph07888 Level 1

      Hi All,

       

      I might be having a really stupid moment and this could be really simple but...

       

      When using the DatePicker with ADDT I can't see a function to say you can't choose a date in the past.

       

      Is there such an option or is this code driven?

       

      I have tryed {NOW_DT} in code but that just give me an error.

       

      Please let me know

       

      Cheers,

      Joe

        • 1. Re: Using DatePicker but can choose dates in past
          Günter Schenk Level 4

          The Date Picker doesn´t allow for restricting the date range, but using the placeholder {NOW} for the current date should work in a form validation rule. {NOW_DT} means "the current date AND time", and this value is probably not set respectively doesn´t match the type of the corresponding table column, who knows ?

           

          Cheers,

          Günter

          • 2. Re: Using DatePicker but can choose dates in past
            Joseph07888 Level 1

            Once again thank you very much Gunter!!!

            • 3. Re: Using DatePicker but can choose dates in past
              Albert S. Level 3

              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.

               

               

              • 4. Re: Using DatePicker but can choose dates in past
                Albert S. Level 3

                Hi,

                Sorry posted on the wrong thread. DOH!.