javascript - How to check whether the checkboxlist is checked atleast one in Struts2? -
i'm working in struts2 framework. have checkboxlist in code.
<div id="mycheckbox"> <td> <s:checkboxlist theme="simple" name="claimlistview.claimstatus" list="#{'u':'unprocessed', 'p':'processed','r':'routed','s':'sent'}" id="claimstatus" required="true" value="defaultcolor"/> </td> </div>
so want field required field. mean user should select @ least 1 check box. else error msg should throwed , prevent form submitted. how can achieve ?
i tried in jquery given below code.
var n = $("#mycheckbox input:checked").length; alert("the count : "+n); if (n>0) { return true; } else{ return false; }
i know i'm missing something. can me, i'm getting wrong ?
finally found out solution own question. below script working fine.
var n = $('input[name="claimlistview.claimstatus"]:checkbox:checked').length; if (n>0) { return true; } else{ return false; }