李潇伦      | 分类:其他编程语言      | 浏览2051次                                                                                                                    

 p>用户密码:<asp:textbox id="password1" textmode="Password" runat="server"/> 
<p>确认密码:<asp:textbox id="password2" textmode="Password" runat="server"/>
<asp:RequiredFieldValidator id="require2" ControlToValidate="password1" ErrorMessage="必须输入密码" runat="server"/>
<asp:CompareValidator id="Compare1" ControlToValidate="password1" ControlToCompare="password2" ErrorMessage="密码和确认密码必须一致" runat="server" />
<p>用户年龄:<asp:textbox id="age" runat="server"/>
<asp:RequiredFieldValidator id="require3" ControlToValidate="age" ErrorMessage="必须输入年龄" runat="server"/> <asp:RangeValidator id="Range1" ControlToValidate="age" MinimumValue="1" MaximumValue="150" ErrorMessage="年龄应该在1到150之间" Type="Integer" runat="server" />
<p>电子信箱:<asp:textbox id="email" columns="50" runat="server"/>
<asp:RequiredFieldValidator id="require4" ControlToValidate="email" ErrorMessage="必须输入E-mail地址" runat="server"/> <asp:RegularExpressionValidator id="Regular2" ControlToValidate="email" ValidationExpression=".{1,}@.{1,}\.[a-zA-Z]{2,3}" ErrorMessage="必须输入正确的E-mail地址" runat="server" />
<p><asp:button id="Enter" text="提 交" onClick="Enter_Click" runat="server" />
<p><asp:label id="message" runat="server"/>
</form>
 

   

【确认密码】为必填项,并且与【用户密码】一致
【用户年龄】为必填项,并且要在1到150之间
【电子信箱】为必填项,并且要符合电子邮箱的格式
点【提 交】按钮的时候,如果上面三个输入方式不符合上面的要求就会出现红色的提示信息