Anthony Matovu
asked on
Limiting entry to numeric characters for a textbox
I want to limit entry into a text box to numeric characters (vb.net)
You may find a list of JavaScript KeyCodes here:
Like this
<asp:TextBox runat="server" id="txtNumber" />
<asp:RegularExpressionVali dator runat="server" id="rexNumber" controltovalidate="txtNumb er" validationexpression="^[0- 9]+$" errormessage="Please enter digit only!" />
OR
<asp:TextBox runat="server" id="txtNumber" />
<asp:RegularExpressionVali dator runat="server" id="rexNumber" controltovalidate="txtNumb er" validationexpression="\d+" errormessage="Please enter digit only!" />
<asp:TextBox runat="server" id="txtNumber" />
<asp:RegularExpressionVali
OR
<asp:TextBox runat="server" id="txtNumber" />
<asp:RegularExpressionVali
Try This:
<asp:RegularExpressionVali dator runat="server" id="rexNumber"
controltovalidate="txtSN1" validationexpression="(^-? \d\d*\.\d* $)|(^-?\d\ d*$)|(^-?\ .\d\d*$)" errormessage="Please enter digit only!" />
http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3
<asp:RegularExpressionVali
controltovalidate="txtSN1"
http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3
ASKER
Sorry, it is a windows application, not an asp.net application
thank you
thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
2) Link the above JavaScript Variable to the requested TextBox as follows in Page_Load:
Open in new window