Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so everyone will know you have been helped.
This is what i have done but it still gives me an error when i enter 10. Any suggestions.
<
asp:CompareValidator
ID="CompareValidator1"
runat="server"
ErrorMessage="Must be Greater than zero"
ControlToValidate="tbQty"
ValueToCompare="0"></asp:CompareValidator>
You'll need to set Operator="GreaterThan". The default operator is Equals, so without setting it, it will only allow 0. And setting Type="Integer" will cause non-integer values to fail validation.
Aaron
Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so everyone will know you have been helped.
This worked for me , Thanks for pointing me in right direction. Cheers, Shilpa.
<
asp:RangeValidator
ID="RangeValidator1"
runat="server"
ErrorMessage="Value must be greater than zero."
ControlToValidate="tbQty"
MinimumValue="1"
MaximumValue="1000"
Type="Integer"></asp:RangeValidator>
Sharonrao123
Member
32 Points
268 Posts
RegularExpression Validator for number greater than zero
May 17, 2007 02:04 AM|LINK
hello all,
i have a textbox which should take only numbers greater than zero and no decimals. i have tried these two validation expressions
ValidationExpression="[1-9]" - This only allows me to enter single digit numbers, gives error if i enter 10.
ValidationExpression="^[1-9]\d+$" - This only allows 2 digit number, gives error if i enter 1.
Any suggestions please. cheers, shilpa.
agolden
Star
7893 Points
1060 Posts
Re: RegularExpression Validator for number greater than zero
May 17, 2007 02:24 AM|LINK
Does it need to specifically be a RegularExpressionValidator? You could use a CompareValidator
Hope that helps.
Aaron
Sharonrao123
Member
32 Points
268 Posts
Re: RegularExpression Validator for number greater than zero
May 17, 2007 02:41 AM|LINK
Thanks for the reply,
This is what i have done but it still gives me an error when i enter 10. Any suggestions.
<
asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Must be Greater than zero" ControlToValidate="tbQty" ValueToCompare="0"></asp:CompareValidator>agolden
Star
7893 Points
1060 Posts
Re: RegularExpression Validator for number greater than zero
May 17, 2007 02:55 AM|LINK
You'll need to set Operator="GreaterThan". The default operator is Equals, so without setting it, it will only allow 0. And setting Type="Integer" will cause non-integer values to fail validation.
Aaron
Sharonrao123
Member
32 Points
268 Posts
Re: RegularExpression Validator for number greater than zero
May 17, 2007 02:57 AM|LINK
Thanks Aaron,
This worked for me , Thanks for pointing me in right direction. Cheers, Shilpa.<
asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Value must be greater than zero." ControlToValidate="tbQty" MinimumValue="1" MaximumValue="1000" Type="Integer"></asp:RangeValidator>chandana
Participant
1356 Points
378 Posts
Re: RegularExpression Validator for number greater than zero
May 17, 2007 03:46 AM|LINK
try with following
[1-9]+