Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text box validation to enter value only more than zero

I need a asp.net text box validation to enter value which is above zero;

Not less than zero or zero


1 Answers

You can set up a CompareValidator with those conditions.
Add a RequiredFiedlValidator if you don't want it to be left empty.

The aspx looks like this:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
      ControlToValidate="TextBox1" ErrorMessage="Must be &gt; 0"
      Operator="GreaterThan" Type="Integer"
      ValueToCompare="0" />
like image 147
Henk Holterman Avatar answered Dec 12 '25 05:12

Henk Holterman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!