Friday, 23 October 2015

while loop checkbox validation using javascript

<script>
function validate(){
if($('input[name="check_list[]"]:checked').length == 0) {
    alert('No checkbox is checked');
    return false;
}
  return true;
}
</script>


<form action="" method="post"  onsubmit="return validate();"  enctype="multipart/form-data">

  <input type="checkbox" name="check_list[]" value="">
 <input type="checkbox" name="check_list[]" value="">
  <input type="checkbox" name="check_list[]" value=""> 
 <input type="checkbox" name="check_list[]" value=""> 

<button  class="btn  btn-danger" type="submit" name="upload"> Send </button>
</form>


No comments:

Post a Comment