Checkbox validation for multiple checkboxes- jquery

Posted: July 30, 2014 in Javascript, Jquery

Use the following example to check the any one of checkbox checked or not

 

<input type=”checkbox” name=”test[0]”  value=”1″  />
<input type=”checkbox” name=”test[1]”   value=”1″  />
<input type=”checkbox” name=”test[2]” value=”1″  />
<input type=”checkbox” name=”test[3]”  value=”1″  />
<input type=”button” id=”submitbutton” />

 

$(“#submitbutton”).click(function () {
if ($(‘input[name^=test]:checked’).length <= 0) {
alert(“No checkbox checked”)
}
});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s