validation of two dates (from-to)

  • 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 

  • Carina
    Replied 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.

    validation of two dates (from to) Image 1 Screenshot 40

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

    validation of two dates (from to) Image 2 Screenshot 51

    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":

    validation of two dates (from to) Image 3 Screenshot 62

    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

  • unicefethiopia
    Replied on July 2, 2014 at 4: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?

  • jonathan
    Replied on July 2, 2014 at 8: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

    validation of two dates (from to) Image 1 Screenshot 20

     

    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!

     

  • unicefethiopia
    Replied on July 3, 2014 at 3:29 PM

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

     

  • Carina
    Replied on July 3, 2014 at 4:22 PM

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

    Thank you.