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

 
  
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 >

转载于:https://www.cnblogs.com/qiuweiguo/archive/2011/06/14/2080236.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值