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

How to disallow a blank and a 0 to be entered on a RadNumericTextBox

1 Answer 126 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Herman Gouw
Top achievements
Rank 2
Herman Gouw asked on 27 Mar 2012, 07:34 AM
I am using RadControls for ASP.NET AJAX Q1 2012 in my current project.

I have a web page which has a RadNumericTextBox  as follows:

<telerik:RadNumericTextBox ID="rntbInitialLevel" MaxLength="4" MinValue="0" MaxValue="100" Type="Number" Width="35" runat="server">
    <NumberFormat DecimalDigits="1" />
</telerik:RadNumericTextBox>

The valid value that can be entered on the RadNumericTextBox ranges from 0.10 to 100.0.

I would like to disallow the user from entering a blank, "0", "00", "000", "0000", "0.0", "0.00", "00.0"

Can you please show me how to do this?

Thanks,
Herman

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2012, 07:59 AM
Hello,

One suggestion is that you can use a combination of MinValue and RequiredFieldValidator. Following is the sample code that I tried.

ASPX:
<telerik:RadNumericTextBox ID="rntbInitialLevel" MaxLength="4" MinValue="0.1" MaxValue="100" Type="Number" Width="35" runat="server">
  <NumberFormat DecimalDigits="1" />
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Shouldn't be empty" ControlToValidate="rntbInitialLevel">
</asp:RequiredFieldValidator>

Hope it helps.

Thanks,
-Shinu.
Tags
General Discussions
Asked by
Herman Gouw
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or