user3628391
user3628391

Reputation: 17

How to check validation of value range of radNumericTextBox?

How to check validation of value range of radNumericTextBox ? I want to stop insert , when I enter incorrect value in radNumericTextBox. When I enter incorrect value in radNumericTextBox , and click on btnInsert, controls change value into 0 and save.

My code is:

 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true" ShowSummary="false" ValidationGroup="oppSub" DisplayMode="List" />
    <div dir="rtl">
        <telerik:RadNumericTextBox ID="txtDiscount" Type="Percent" MinValue="0" MaxValue="100"
            AllowOutOfRangeAutoCorrect="false" ShowSpinButtons="true"
            ValidationGroup="oppSub"
            runat="server">
            <NumberFormat KeepNotRoundedValue="false" DecimalDigits="3" DecimalSeparator="."
                AllowRounding="false"></NumberFormat>
        </telerik:RadNumericTextBox>

        <asp:Button ID="btnInsert" Text="save" runat="server"
            ValidationGroup="oppSub"></asp:Button>
    </div>

Upvotes: 1

Views: 2241

Answers (1)

crthompson
crthompson

Reputation: 15865

To validate a telerik RadNumericTextBox you need a range validator.

<asp:RangeValidator ID="NumericTextBoxRangeValidator" 
                    runat="server" 
                    ControlToValidate="txtDiscount"
                    ErrorMessage="Please enter in a number between 0 and 100." 
                    Display="Dynamic"
                    MaximumValue="100" MinimumValue="0" Type="Decimal">
</asp:RangeValidator>

This will alert the user that they have entered and invalid date and prompt for another.

See Telerik's example of the validator at work

Upvotes: 1

Related Questions