Pages

Validation of CheckboxList Items

  • Here validating a checkboxlist item.(Atleast one checkbox should be selected)
  • call JavscriptFunctionCode on any javascript Events or from codebehind as required

Javasript Function Code

function validateChklist() { var list = document.getElementById('<%=CheckBoxList1.ClientID%>'); var child =""; for(i = 0; i < list.childNodes.length; i++) { //checkbox list id is 'CheckBoxList1' replace according id of checkboxlist child =document.getElementById('CheckBoxList1$'+ i) if(child.checked) { alert('Thanks for Selecting'); return true; } alert('Please Select atleast one item check box list'); return false; } }