
<%@ Page Language="VB"%>
 <html>
 <head>
  </head>
<title>第二十一例 RangeValidator、RequiredFieldValidator、RegularExpressionValidator 和ValidationSummary控件使用</title>
 <body>
  <head>
    <script language="VB" runat=server>
	Sub Button_Click( sender As Object, E As EventArgs )
     
		lblOutput.Text = ""
'进行范围验证
	       	Range1.Validate()

         	if  Page.IsValid = true     
            		lblOutput.Text = "验 证 通 过!"        
         	else          
         		lblOutput.Text = "验证没有通过!"
        	End If
	End Sub 
   
    </script>
 
 </head>
    <h3><font face="Verdana">第二十一例 RangeValidator、RequiredFieldValidator、RegularExpressionValidator 和validationSummary控件使用</font></h3>
    <p>
 
    <form runat="server">
 
       <table cellpadding=10>
          <tr>
             <td>
                <table bgcolor="#eeeeee" cellpadding=10>
 
                   <tr>
                      <td colspan=3>
                         <font face=Verdana size=2><b>信用卡信息</b></font>
                      </td>
                   </tr>
                   <tr>
                      <td align=right>
                         <font face=Verdana size=2>信用卡类型:</font>
                      </td>
                      <td>
                         <asp:RadioButtonList id=RadioButtonList1 
                              RepeatLayout="Flow"
                               runat=server>
                            <asp:ListItem>京  卡</asp:ListItem>
                            <asp:ListItem>牡丹卡</asp:ListItem>
                         </asp:RadioButtonList>
                      </td>
                      <td align=middle rowspan=1>
<!--此控件哟用于检验是否输入了值-->
                         <asp:RequiredFieldValidator 
                              id="RequiredFieldValidator1"
                              ControlToValidate="RadioButtonList1" 
                              ErrorMessage="信用卡类型. "
                              Display="Static"
                              InitialValue="" Width="100%" runat=server>
                            *
                         </asp:RequiredFieldValidator>
                      </td>
                   </tr>
                   <tr>
                      <td align=right>
                         <font face=Verdana size=2>信用卡卡号:</font>
                      </td>
                      <td>
                         <asp:TextBox id=TextBox1 runat=server />
			 <asp:label id=lblOutput ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server />
                      </td>
                      <td>
<!--此控件哟用于检验是否输入了值-->
                         <asp:RequiredFieldValidator 
                              id="RequiredFieldValidator2"
                              ControlToValidate="TextBox1" 
                              ErrorMessage="信用卡卡号. "
                              Display="Static"
                              Width="100%" runat=server>
                            *
                         </asp:RequiredFieldValidator>
                      </td>
                   </tr>
 
                   <tr>
                      <td></td>
                      <td>
                         <asp:Button 
                              id=Button1 
                              text="验  证" 
			      OnClick="Button_Click"
                              runat=server />
                      </td>
                      <td></td>
                   </tr>
                </table>
             </td>
             <td valign=top>
                <table cellpadding=20>
                   <tr>
                      <td>
<!--此控件用于检验是否所有的控件均被使用-->
                         <asp:ValidationSummary 
                              id="valSum" 
                              DisplayMode="BulletList" 
                              runat="server"
                              ShowSummary="True"
                              HeaderText="您必须输入下列值:"
                              Font-Name="verdana" 
                              Font-Size="12"/>
<!--此控件用于检验输入的范围是否正确-->
			<asp:RangeValidator id="Range1" 
          		 ControlToValidate="TextBox1" 
			Type="Integer"
			MinimumValue =10000
			MaximumValue =99999			
          	 	runat="server"/>
<!--此控件用于检验输入的信用卡号是否为五位-->
		<asp:RegularExpressionValidator id="RegularExpressionValidator1" 
                     runat="server"
                     ControlToValidate="TextBox1"
                     ValidationExpression="^\d{5}$"
                     Display="Static"
                     Font-Name="verdana" 
                     Font-Size="12pt"> 
                   <BR>信用卡必须是五位数字 
                </asp:RegularExpressionValidator>
                      </td>
                   </tr>
                </table>
             </td>
          </tr>
       </table>
 
    </form>
 
 </body>
 </html>