We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36549
    • 572 Posts
    Hi,

    Could anyone help with adding a field to an existing application form that requires the user to give their date of birth and if not over the age of 21 have a message display?
    Ideally the DOB would be a datePicker or something similarly user friendly.
    The dates would have to go back to allow for users over the age of 70 and the 21 years restriction would have to take in account the actual 'day' and not just the year. For instance if I was 21 yesterday and filling out the form my age should be accepted.

    Hope that makes some sense but if anyone can help please feel free to pm me or respond to this thread. The budget isn't great but it is a paying job.

    Cheers

    J
      www.9thwave.co.uk
         WEB | DESIGN | PRINT
      • 3749
      • 24,544 Posts
      FormIt has validates for minValue and maxValue, but I don't know if they will work with dates (and they won't give you a datepicker): http://rtfm.modx.com/display/ADDON/FormIt.Validators

      NewsPublisher will give you a datepicker, but no min or max checking (though that could probably be added with some custom JS. There's an example of a booking system that does mess with date ranges in the NewsPublisher package (though I didn't write it).

      The best solution would be to use JavaScript for validation. Something like this code for use with the JQueryUI datepicker: http://www.phpeveryday.com/articles/jQuery-UI-Minimum-and-maximum-dates-For-Datepicker-P1018.html


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 11 years, 8 months ago.]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36549
        • 572 Posts


        Thanks for this BobRay.
        I'll give this a go but it's a bit beyond my knowledge to be honest so if you want/can help at all, like i said it's a paid job.
        Please pm if anyone can help out with this as i'm sure i'll still need it.
        I'll stick the solution here once complete.

        Cheers
          www.9thwave.co.uk
             WEB | DESIGN | PRINT
          • 3749
          • 24,544 Posts
          I understand. I don't have time to take that on (and you can probably find someone who is better at JS date arithmetic than I am) . wink


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting