I need a asp.net text box validation to enter value which is above zero;
Not less than zero or zero
I need a asp.net text box validation to enter value which is above zero;
Not less than zero or zero
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 > 0"
Operator="GreaterThan" Type="Integer"
ValueToCompare="0" />
This is a bit hackey but you could also use a range validator that sets the min value to 1 and the max value to some very large integer that isn't likely to be entered. Also, as mentioned above don't forget the requried field validator to ensure that something is entrered into the text box.