How to check a checkbox is not selected
<li>
<label><spring:message code="label.roles"/></label>
<form:checkbox path="roleIds" value="1" />
<label><spring:message code="label.users"/></label>
</li>
<li>
<label> </label>
<form:checkbox path="roleIds" value="2" />
<label><spring:message code="label.articles"/></label>
</li>
<li>
<label> 开发者_如何转开发;</label>
<form:checkbox path="roleIds" value="3" />
<label><spring:message code="label.contents"/></label>
</li>
<li>
Now what i want is to give an error message if any of checkbox is not selected , how can i do it Using jquery
if ($("input[name='roleIds']:checked").length == 0) {
alert("at least one checkbox must be checked");
}
if ($("input[name=roleIds]").not(":checked").length) {
alert("some checkboxes aren't checked");
}
精彩评论