added feature to use checkbox to force a field to be validated #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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