ASP.NET Number validation in Textbox

Only Number validation in Textbox of ASP.NET Using Regular Expression validator
Only numbers can enter into that Textbox

We can use Regular expression validator for this:
In the validation expression property keep ^\d+$.

<asp:TextBox ID=”TextBox1″ runat=”server” Style=”z-index: 100; left: 259px; position: absolute;
top: 283px” ValidationGroup=”check”></asp:TextBox>

<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>
——-

equivalent telerik control
<telerik:RadNumericTextBox ID=”RadNumericTextBox1″ runat=”server” Type=”Number” NumberFormat-DecimalDigits=”0″>
                        </telerik:RadNumericTextBox>
<asp:RequiredFieldValidator ID=”NumercTextBoxRequiredFieldValidator” runat=”server”
Display=”Dynamic” ControlToValidate=”RadNumericTextBox1″ ErrorMessage=”Please, select an year number!” />
<asp:RangeValidator ID=”NumericTextBoxRangeValidator” runat=”server” ControlToValidate=”RadNumericTextBox1″
ErrorMessage=”Year number should be a non negative less than 50.” Display=”Dynamic”
MaximumValue=”50″ MinimumValue=”0″ Type=”Integer” />

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: