Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Thursday, July 31, 2014

Validation checkbox control using JavaScript:

Validation control using JavaScript: 

In asp.net we can Access asp.net web controls by using JavaScript language in client site. Then we check validation of each control.Remember that we can easily Access only those Asp.net controls which make our own html tag at using time. 

Check box validation (E
nable check box using 

JavaScript)




For validate check box by JavaScript we use a script function, this is

      function validate(chkbox)
       {
        if (chkbox.checked == 1)
            alert("you are select given check box");
        else
            alert("you are not select given check box......")
      
       }

In this function we pass check box control as argument in this function.
Then use conditional statement for check that checks box is checked or not
According to the condition gives alert message with in the if and else condition.

And On web page we take one html button and one html checkbox control.
Button control use to call JavaScript validation function on client site.

Html check box Declaration:


<p>
<input type=checkbox name=chkbox style="height: 22px; width: 25px"/>select this box(checked)</p>
<p>
in the html language it must that you define which type of input you want. For this define

        type="checkbox";

Html button Declaration:


<input type=button value="check" onclick="return validate(chkbox);"
        style="width: 106px; height: 39px"/></p>

Use this check box and button control we make a web page and see the Example of html checkbox.

Example of Check box validation:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
    function validate(chk) {
        if (chk.checked == 1)
            alert("you are checked");
        else
            alert("can i Checked......")
        chk.checked = 1;
    }
</script>
</head>
<body>
<div align="center">
<h1>Checkbox Validation using JavaScript</h1></div>
<div align="center" style="font-size: x-large">
<form runat="server">
<input type=checkbox name=chkbox style="height: 22px; width: 25px">select this box(checked)
<p><input type=button value="check" onclick="return validate(chkbox);"
        style="width: 106px; height: 39px"></div>
</form>
</body>
</html>
 
javascript checkbox example onclick,
                               javascript checkbox example onclick,


Other Java Script Related Post :

No comments:

Post a Comment