Checkbox status changing onkeypress
<p>I am using the JavaScript to disable keyboard if checkbox is not checked and to enable only numbers if checkbox is checked.</p>

<p>My code is.</p>

<pre><code>    &lt;script type="text/javascript"&gt;
     function isNumberKey(evt)
  {
      if(document.getElementById("check1").checked=false)
        {
        var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
     return false;
     return true;
        }
    else
        { 
         var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode &gt; 1 &amp;&amp; charCode &lt; 127)
        return false;
            return true;
         }
  }
    &lt;/script&gt;
</code></pre>

<p>HTML code</p>

<pre><code>&lt;asp:CheckBox ID="check1" runat="server"/&gt;
&lt;asp:TextBox ID="tbxt1" runat="server" MaxLength="6" Width="200" onkeypress="return isNumberKey(event);" TextMode="Password" autocomplete="off" /&gt;
</code></pre>

<p>In default as checkbox is not checked so JavaScript is not allowing me to use my keyboard. This is fine. When I change my checkbox status to checked and tried pressing a key. OnKeyPress event the checkbox status is changing to unchecked. Is there anything wrong in my code?</p>
