Use asp:RangeValidator to check the value range in an asp:textbox : RangeValidator « Validation « ASP.NET Tutorial






<html><body>
   <form runat="server">
      <asp:Label id="lblMessage" runat="server" /><br>
      <asp:Panel id="Panel1" runat="server">
         <table>
         <tr>
            <td valign="top">City, State, ZIP (5-digit):</td>
            <td valign="top">
               <asp:TextBox id="tbCity" 
                  runat="server" />,
               <asp:TextBox id="tbState" runat="server" size=2 />&nbsp;
               <asp:TextBox id="tbZIP" runat="server" size=5 /><br>
               <asp:RegularExpressionValidator runat="server"
                  ControlToValidate="tbZIP"
                  ValidationExpression="[0-9]{5}"
                  ErrorMessage="That is not a valid ZIP" /><br>
               <asp:RangeValidator runat="server"
                  ControlToValidate="tbZIP"
                  MinimumValue="00000" 
                  MaximumValue="22222"
                  Type="String"
                  ErrorMessage="You don't live in the correct region" />
            </td>
         </tr>

         <tr>
            <td colspan="2" valign="top" align="right">
               <asp:Button id="Submit" runat="server" 
                  text="Add" />
            </td>
         </tr>
         </table>
      </asp:Panel>
   </form>
</body></html>








8.8.RangeValidator
8.8.1.RangeValidator checks whether the value falls between a minimum and maximum value
8.8.2.Set Minimum/Maximum Value, ErrorMessage, ControlToValidate, EnableClientScript for asp:RangeValidator (C#)
8.8.3.Manual Validation
8.8.4.Use asp:RangeValidator to check the value range in an asp:textbox
8.8.5.asp:RangeValidator is converted to JavaScript code after loading in client side
8.8.6.Using the RangeValidator control to test an integer value
8.8.7.Using the RangeValidator control to test a string date value (C#)
8.8.8.Using the RangeValidator control to test a string date value (VB.net)
8.8.9.RangeValidator for number and date
8.8.10.Birthday range