This is a migrated thread and some comments may be shown as answers.

NumericTextBox Validation Question

2 Answers 160 Views
Input
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Oct 2012, 03:32 PM
Hi,

My team is having an issue with the NumericTextBox and the developer currently having the issue asked that I post his question in the forum on his behalf since he is having a technical issue with his workstation that is preventing him from posting himself.

"I have a NumericTextBox that has MinValue and MaxValue properties.I have a ValidationSummary control which has a RequiredFieldValidator connected to another asp.net TextBox control.

When the user hits the Save button and validation takes place, is there a way for invalid values in the NumericTextBox control, for example value entered is less than the MinValue, to be displayed in the ValidationSummary control without hooking up an additional asp.net validation control?"

Thanks,

Andrew

2 Answers, 1 is accepted

Sort by
0
Accepted
Angel Petrov
Telerik team
answered on 10 Oct 2012, 01:49 PM
Hi Andrew,

The desired logic is not supported because when setting MinValue and MaxValue the RadNumericTextBox auto corrects the data. You could use a RangeValidator instead and that way you would be able to display the validation summaries. This approach is shown in the following code snippet:
<telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox1" >
    </telerik:RadNumericTextBox>
    <asp:RangeValidator ID="NumericTextBoxRangeValidator" runat="server" ControlToValidate="RadNumericTextBox1"
    errormessage="Year number should be a non negative less than 100."
    MaximumValue="100" MinimumValue="0" Type="Integer" />
    <asp:TextBox ID="TextBox1" runat="Server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1"
    errormessage="Please enter your name!"
    Text="<br>Please write something in 2nd  Box."></asp:RequiredFieldValidator>
    <asp:Button ID="btnSubmit" runat="Server" OnClick="WriteTextBoxValue" Text="Submit" />            
    <asp:ValidationSummary ID="ValidationSummary" runat="Server"
    ShowSummary="true" EnableClientScript="true"  DisplayMode="List"
    HeaderText="Following error occured." />

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
answered on 15 Oct 2012, 10:16 PM
This worked great for us, thanks a lot!

Andrew
Tags
Input
Asked by
Andrew
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or