Datefield not before second date field

Datefield not before second date field

rob1strob1st Posts: 84Questions: 22Answers: 0

Hi,

I have tried searching this, but not seeing what I need, apologies if I have missed it.

Is there a way ensure that date A is not before (less than) date B? or do I need to just function this with JS?

Thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,257Questions: 26Answers: 4,761

    If you are asking how to sort dates see this blog.

    Kevin

  • rob1strob1st Posts: 84Questions: 22Answers: 0

    Hi Kevin, no it was more of a validation I was looking for.

    If filling in a form, Date A cannot be before Date B

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    You can use dependent() for that, to compare the two values, and then error the field with field().error() if it's before. You can use Moment.js for the calculation, as it's excellent for all time/date based operations.

    Colin

  • rob1strob1st Posts: 84Questions: 22Answers: 0

    Thanks Colin.

Sign In or Register to comment.