Suppose you have a check box with ID agree_checkbox
. You can check whether the checkbox is checked using this jQuery code:
$('#agree_checkbox').prop('checked')
Here is a complete example:
Here is the code that does the check:
$("#myform").on("submit",function(form)
{
if(!$("#agree_checkbox").prop("checked"))
{
$("#agree_chk_error").show();
}
else
{
$("#agree_chk_error").hide();
}
return false;
})
See Also
- Checkbox checked validation using JavaScript
- How to do multiple checkbox validation in Javascript
- Google reCaptcha 2 JavaScript Validation (client side)
- Custom styled checkboxes with Bootstrap
- HTML Form Checkbox with required validation
- HTML Form with Checkboxes examples and sample code
- How to create a dropdown with checkbox options with Bootstrap Style
- How to create checkbox in Bootstrap style ?
- How to get checkbox value in form submission