Sunday, September 9, 2012

Alphabets validation in Asp.net with javascript



<script type="text/javascript">

       function validate(key)
       {
           
           var keycode = (key.which) ? key.which : key.keyCode;
           var phn = document.getElementById('text');
           //comparing pressed keycodes
           if ((keycode < 65 || keycode > 90) && (keycode < 97 || keycode > 122))
            {
               return false;
           }
           
         
       }
</script>


<asp:TextBox ID="text" runat="server" onkeypress="return validate(event);"></asp:TextBox>

Please enter ID as your textbox id in function  above
And this function in head section

No comments :

Post a Comment