I am working on a form in which the user enters a total number, and then enters more values ββinto other fields, which are a division of this amount. For instance:
<input type="text" name="total" /> <input type="text" name="portion[1]" /> <input type="text" name="portion[2]" /> <input type="text" name="portion[n]" />
If the user enters the total number 123.45, then parts 1 - n must be filled in so that their values ββare up to 123.45. The field of each section must be a positive number or 0, but these are the only other restrictions on them.
The jquery.validate plugin has an equalTo validation method, but it might seem like it only handles one field, not a set.
Is there any way
- Define a validation rule that will check the total number of field groups against the common field
- Get a separate message for a group of fields if they do not add up
source share