ASP.NET Sever Controls Validation using JavaScript / jQuery!

Validation

Roopesh's Space

Numeric Textbox
  1. <div>
  2.      <labelstyle="float:left;">Enter you PIN:</label><asp:TextBoxrunat="server"onkeydown="return NumericTextBox(event);"></asp:TextBox>
  3.    </div>
  4.    <scripttype="text/javascript">
  5.        
  6.        function NumericTextBox(evt) {
  7.            var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
  8.            if (charCode == 8 || //backspace
  9.                 charCode == 46 || //delete
  10.                 charCode == 13)   //enter key
  11.            {
  12.                returntrue;
  13.            }
  14.            elseif (charCode >= 37 && charCode <= 40) //arrow keys
  15.            {
  16.                returntrue;
  17.            }
  18.            elseif (charCode >= 48 && charCode <= 57) //0-9 on key pad
  19.            {
  20.                returntrue;
  21.            }
  22.            elseif (charCode >= 96 && charCode <= 105) //0-9 on num pad
  23.            {
  24.                returntrue;
  25.            }
  26.            else
  27.                returnfalse;
  28.  
  29.        } //end:NumericTextBox function
  30.    

View original post 683 more words

Leave a comment