I'm trying to check before submitting the form to see if the user has checked the checkbox. I've read a lot of stackoverflow, but I mostly find options for multiple checkboxes. In my case, I have only one checkbox to check. How can i do this? Now I have done this:
jQuery validation:
rules: {
accept: {
required: true
},
messages: {
accept: {
required: "Check the box is required"
}
}
}
HTML Markup:
<input class="input__custom" type="checkbox" id="accept" name="accept" value="1" >
But it doesn't work, please tell me what am I doing wrong?
console.log(document.getElementById('accept').checked)$("#accept").is(':checked')Read other answers also. It would also be helpful for future notice to make a working snippet, you can use <> button in editor here to create one.