validation of two dates (from-to)

  • Profile Image
    unicefethiopia
    Asked on June 30, 2014 at 10:15 AM

    Hello, 

    I have a form where two dates should be entered (from - to) . The "To" date should be after the "From" date. 

    Is it possible to validate the second date to later than the first date? 

    Thanks 

  • Profile Image
    Carina
    Answered on June 30, 2014 at 11:46 AM

    I tried a workaround using 3 form calculation fields. In the "from" calculation field I added the date "from" and did the same with the "to" field.

    I added a third calculation field (total) where I would subtract the calculation fields "to" - "from":

    I also added a Text field, under Form Tools with a warning message that will show if the "to" date is after the "from" date.

    I added a condition that if "total" is less than 0 show "error message":

    You can clone the test form if you wish:

    http://form.jotformpro.com/form/41804589657973?

    Let us know if this is a solution for you.

    Thank you

  • Profile Image
    unicefethiopia
    Answered on July 02, 2014 at 04:53 AM

    Hi, thanks for the solution, 

    The only difference is the error message but it does not prevent submission of the form! 

    Is there a way to prevent the submission?

  • Profile Image
    jonathan
    Answered on July 02, 2014 at 08:31 AM

    Hi,

    You can just use the condition to hide the Submit button if the selected dates is true.

    Example, if date FROM is after date TO which is false -- then hide submit button. This will prevent form submission base on condition.

    I also created a demo form http://www.jotform.me/form/41823271891457

    It only requires the From and To date field to calculate (lesser field requirement)

    The calculation is like this

     

    If you test the form, you will not be able to submit if the TO date is less than FROM date.

     

    Inform us if you need more assistance.

    Thanks!

     

  • Profile Image
    unicefethiopia
    Answered on July 03, 2014 at 03:29 PM

    Thanks. it worked well after i cloned your form and checked the conditions.

     

  • Profile Image
    Carina
    Answered on July 03, 2014 at 04:22 PM

    I'm glad to hear it. If you need further support please let us know.

    Thank you.