victorjonsson/jQuery-Form-Validator — pull request #17 by stevewasiura (2012-07-03 20:38:35+00:00)
Title: added feature to use checkbox to force a field to be validated

I needed a way to use a checkbox to control if a separate field needed to be validated.

for example, if you wanted to be notified of replies to your comment, you would check a checkbox.
if that checkbox was checked, then the email form field would need to be validated.

the email address form field has the attribute "data-validation-optional" equal to "true"
that allows us to skip validation on that form field if it is blank.

i used the same concept and added a additional attribute to the email form field.
the attribute is named "data-validation-if-checked"
the value of that attribute is the name of the checkbox type field in the form.

the script detects if the form field has that attribute, then gets it's value, finds the form element, determines if it is checked, and sets a var value.

the var value is used in the validateInput function to determine if the element should be forced to validate, appended to optional == 'true' statement

tested in G Chrome , Firefox 13.0.1 & IE 8