开发者

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>&nbsp;</label> 
            <form:checkbox path="roleIds" value="2" />

            <label><spring:message code="label.articles"/></label> 
        </li>
        <li>
            <label>&nbsp开发者_如何转开发;</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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜