In fact, a form might need to validate multiple fields which any of them depends to each
other. Changing value of any field will effect to the validity of other one.
For instance, a form for creating new event often have two fields for indicating the start
and end date of the event. The start date must be earlier than the end one. And vice versa,
the end date must be later than the start one. User usually fill in the start date field
first, and then the end date one. If the end date is not later than the start one, the form
informs that the end date is not valid. It behaves as expected.
For this specific form, we can use the min and max options provided
by the date validator:
The problem comes out when user try to adjust the start date being earlier than the current
end date. Despite the fact that the end date is valid now, it is still marked as invalid.
In order to fix this, when the start date is valid, we need to revalidate the end date if
it's not valid. The onSuccess callback, isValidField() and revalidateField() methods are used as in the following
code snippet:
You also can trigger the success.field.fv event as seen
in the Comparing
dates example
It's recommended to use a date picker along with the date
input. There are a lot of ejemplos showing how to
integrate FormValidation with popular date picker plugins