验证控件的使用八(分组验证)

  
1 <% @ Page Language = " C# " %>
2
3 < html xmlns = " http://www.w3.org/1999/xhtml " >
4 < head id = " Head1 " runat = " server " >
5 < title > Validation Groups </ title >
6 </ head >
7 < body >
8 < form id = " form1 " runat = " server " >
9 < div >
10 < h1 > St. Louis .NET User Group </ h1 >
11 < p > Username:
12 < asp:TextBox ID = " TextBox1 " Runat = " server " ></ asp:TextBox >& nbsp; Password:
13 < asp:TextBox ID = " TextBox2 " Runat = " server "
14 TextMode = " Password " ></ asp:TextBox >& nbsp;
15 < asp:Button ID = " Button1 " Runat = " server " Text = " Login "
16 ValidationGroup = " Login " />
17 < br />
18 < asp:RequiredFieldValidator ID = " RequiredFieldValidator1 " Runat = " server "
19 Text = " * You must submit a username! "
20 ControlToValidate = " TextBox1 " ValidationGroup = " Login " >
21 </ asp:RequiredFieldValidator >
22 < br />
23 < asp:RequiredFieldValidator ID = " RequiredFieldValidator2 " Runat = " server "
24 Text = " * You must submit a password! "
25 ControlToValidate = " TextBox2 " ValidationGroup = " Login " >
26 </ asp:RequiredFieldValidator >
27 < p >
28 Our main meeting is almost always held on the last Monday of the month.
29 Sometimes due to holidays or other extreme circumstances,
30 we move it to another night but that is very rare. Check the home page
31 of the web site for details. The special
32 interest groups meet at other times during the month. Check the SIG
33 page and visit their individual sites for more information.
34 You can also check our calendar page for a summary of events. < br />
35 </ p >
36 < h2 > Sign - up for the newsletter !</ h2 >
37 < p > Email:
38 < asp:TextBox ID = " TextBox3 " Runat = " server " ></ asp:TextBox >& nbsp;
39 < asp:Button ID = " Button2 " Runat = " server " Text = " Sign-up "
40 ValidationGroup = " Newsletter " />& nbsp;
41 < br />
42 < asp:RegularExpressionValidator ID = " RegularExpressionValidator1 "
43 Runat = " server "
44 Text = " * You must submit a correctly formatted email address! "
45 ControlToValidate = " TextBox3 " ValidationGroup = " Newsletter "
46 ValidationExpression = " \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* " >
47 </ asp:RegularExpressionValidator >
48 < br />
49 < asp:RequiredFieldValidator ID = " RequiredFieldValidator3 " Runat = " server "
50 Text = " * You forgot your email address! "
51 ControlToValidate = " TextBox3 " ValidationGroup = " Newsletter " >
52 </ asp:RequiredFieldValidator >
53 </ p >
54 </ div >
55 </ form >
56 </ body >
57 </ html >

你可能感兴趣的:(验证)