<asp:TextBox ID="txtControl" runat="server" MaxLength="3" Width="30" /> <asp:RangeValidator ID="rv_txtControl" runat="server" ControlToValidate="txtControl" MinimumValue="1" MaximumValue="100" Text="*" Display="Dynamic" ErrorMessage="Range Exceeds"> </asp:RangeValidator> <asp:Button ID="btnValidate" runat="server" Text="Validate" />
Now if I provide values like 0, 101, 200, it will show an error message which is the correct behaviour. But if I provide values like 001 or 002 then also it will show me error message which is not correct behaviour. So how we can handle this situation? You can use the following code instead of the above one.
Changed Code :
<asp:TextBox ID="txtControl" runat="server" MaxLength="3" Width="30" /> <asp:RangeValidator ID="rv_txtControl" runat="server" ControlToValidate="txtControl" MinimumValue="001 MaximumValue="100" Text="*" Display="Dynamic" ErrorMessage="Range Exceeds"> </asp:RangeValidator> <asp:Button ID="btnValidate" runat="server" Text="Validate" />