4/11/2014
Code To Accept Numbers and Strings in Text box using Javs Script
function keyInputsAlphabetsAndNumbers(evt) {
var charCode;
if (window.event)
charCode = window.event.keyCode; //for IE
else
charCode = evt.which; //for firefox
if (charCode == 32) //for <space> symbol
return false;
if (charCode > 31 && charCode < 48) //for characters before 'A' in ASCII Table
return false;
if (charCode > 90 && charCode < 97) //for characters between 'Z' and 'a' in ASCII Table
return false;
if (charCode > 122) //for characters beyond 'z' in ASCII Table
return false;
return true;
}
In Asp.net :-
<asp:TextBox ID="txtLoginName" runat="server" CssClass="TextBox" Width="150px" TabIndex="1" AutoCompleteType="Disabled" onkeypress="return keyInputsAlphabetsAndNumbers(event);" ></asp:TextBox>
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment