Why does jQuery Tools Validator Treat Radio Buttons As Required By Default
Why does jQuery Tools Validator Treat Radio Buttons As Required By Default?
required
attribute. During a recent project using and old version of jQuery Tools Validator, I came across a unique issue in which the validator would automatically validate radio buttons even if they are not set as required.The issue: How to prevent validation on radio buttons that are not set as required?
Some background:
In HTML5, the way to make a field mandatory is to set the required="required" attribute on it. For radio buttons, you're supposed to add that to the first radio button in a group to make it mandatory.
The issue is if you need radio buttons to be optional, they should be this way by default if you didn't set the "required" attribute.
Without using jQuery Tools Validator, it functions properly as an optional radio button group.
Once jQuery Tools Validator is turned on, it forces the radio buttons to be mandatory.
The quick and lazy solution: If your radio buttons are a simple Yes and No question, then decide on a default value and set that one as checked in your html. This will prevent the validation on the radio buttons but is not the most practical of solutions.
Proposed solution by the people on github who originally reported this issue:
Note: This issue appears to be fixed in the latest issue of jQuery Validator
Check out this thread: https://github.com/jquerytools/jquerytools/issues/733