Check box validation in javascript

Check box validation : In java script for selectAll check box and deselect all check box. there are two functions for  selectAll check box and deselect all check box in java script.

<HTML>
 <HEAD>
  <script>
    function selectAllCheckBox(){
        var len = document.testForm.chkb.length;
        //alert(len);
        for(var i=0; i<len; i++){
            //alert(document.testForm.chkb[i].checked);
            document.testForm.chkb[i].checked=true;
        }
    }

    function deselectAllCheckBox(){
        var len = document.testForm.chkb.length;
        //alert(len);
        for(var i=0; i<len; i++){
            //alert(document.testForm.chkb[i].checked);
            document.testForm.chkb[i].checked=false;
        }
    }
  </script>
 
 </HEAD>

 <BODY>
  <form name="testForm">
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <input type="button" name="Select All" value="Select ALL" onclick="selectAllCheckBox();"/>
  <input type="button" name="Deselect All" value="Select ALL" onclick="deselectAllCheckBox()"/>
  </form>
 </BODY>
</HTML>

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java