Range validator control in ASP.NET makes it possible to validate a specified range.
This range could be
- String
- Integer
- Double
- Date
- Currency
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1" MaximumValue="d" MinimumValue="a" Text="*" Type="String"></asp:RangeValidator>
<asp:Button ID="Button2" runat="server" Text="Submit" />
In the above example the text starting from a to d will only be allowed. You can change the below properties.
- ControlToValidate
- MaximumValue
- MinimumValue
- Type
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1" MaximumValue="100" MinimumValue="0" Text="*" Type="Integer"></asp:RangeValidator>
<asp:Button ID="Button2" runat="server" Text="Submit" />
Note: Empty text will not be validated by the control. You'll need to add a Required Field validator to validate the empty text.
No comments:
Write comments