I have a form, where a user has to check at least one checkbox before submitting the form. Is there any plugin that can handle this or maybe jquery that can be applied to my form? Unfortunately I’m a total jquery rookie.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The jQuery Validation Plugin can provide this functionality. You can see a demo of how to implement it for requiring a checkbox here.
Basically, once you load the JavaScript file for the validation plugin on your page, you’ll need to initialize the validator for the form you want to validate. The JavaScript to do this will look something like:
The checkboxes will need to be wrapped in a
<fieldset>tag. The validation of the fieldset can then be activated by adding avalidateattribute to theinputtag for the checkbox. For example:The validation will then be triggered when the form’s submit button(s) are clicked.