Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET: Validate text box contains integer greater than equal to zero?

If I want to validate that a text box contains an integer greater than or equal to zero. Do I need to use TWO asp:CompareValidator controls: one with a DataTypeCheck operator and one with a GreaterThanEqual operator?

Or is the datatype operator redundant? Can I just use a single validator with the GreaterThanEqual operator (and the type set to Integer)?

like image 407
User Avatar asked Mar 29 '10 18:03

User


1 Answers

This should be enough

<asp:RangeValidator id="Range1"
           ControlToValidate="TextBox1"
           MinimumValue="0"
           MaximumValue="2147483647"
           Type="Integer"
           Text="The value must be integer and greater or equal than 0"
           runat="server"/>
like image 191
Claudio Redi Avatar answered Oct 20 '22 00:10

Claudio Redi