Hey,
I have a TextBox and I want that the user type just numbers, not other format.
How can I do that ?
Hey,
I have a TextBox and I want that the user type just numbers, not other format.
How can I do that ?
Use a regular expression validator:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Please Enter Only Numbers" Style="z-index: 101; left: 424px; position: absolute;
top: 285px" ValidationExpression="^\d+$" ValidationGroup="check"></asp:RegularExpressionValidator>
<asp:TexBox runat="server" ID="TexBox1" />
<asp:RegularExpressionValidator runat="server" ValidationExpression="\d+" ControlToValidate="TexBox1" ErrorMessage="Error!" />
One way to do is by using the FilteredTextBox:
ilteredTextBox is an extender which prevents a user from entering invalid characters into a text box. Note that since this effect can be avoided by deactivating JavaScript, you should use this extender as a convenience for your users, but you must never expect that the data being sent to the server consists of "valid" chars only.
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/FilteredTextBox/FilteredTextBox.aspx
see this thread for a jquery solution http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery