web form 服务器控件表单验证

Posted 指间的徘徊

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了web form 服务器控件表单验证相关的知识,希望对你有一定的参考价值。

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidationDemo.aspx.cs" Inherits="Validation.ValidationDemo" %>
 2 
 3 <!DOCTYPE html>
 4 
 5 <html xmlns="http://www.w3.org/1999/xhtml">
 6 <head runat="server">
 7     <title></title>
 8 </head>
 9 <body>
10     <form id="form1" runat="server">
11     <div>
12       <table class="auto-style1">
13         <tr>
14           <td>Name:</td>
15           <td>
16             <asp:TextBox ID="TextName" runat="server"></asp:TextBox>
17             <asp:RequiredFieldValidator ID="RequiredFieldValidator1" 
18               runat="server" ControlToValidate="TextName" 
19               ErrorMessage="Name required">*</asp:RequiredFieldValidator>
20           </td>
21         </tr>
22         <tr>
23           <td>Email:</td>
24           <td>
25             <asp:TextBox ID="TextEmail" runat="server"></asp:TextBox>
26             <asp:RequiredFieldValidator ID="RequiredFieldValidator2" 
27               runat="server" ControlToValidate="TextEmail" Display="Dynamic" 
28               ErrorMessage="Email required">*</asp:RequiredFieldValidator>
29             <asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
30               runat="server" ControlToValidate="TextEmail" Display="Dynamic" 
31               ErrorMessage="Please enter an email" 
32               ValidationExpression="\w+([-+.‘]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
33           </td>
34         </tr>
35         <tr>
36           <td>
37             <asp:Button ID="Button1" runat="server" Text="Register" />
38           </td>
39           <td>&nbsp;</td>
40         </tr>
41       </table>
42 
43     </div>
44         <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
45     </form>
46 </body>
47 </html>

 

以上是关于web form 服务器控件表单验证的主要内容,如果未能解决你的问题,请参考以下文章

vue+Element表单验证之滚动条定位到校验未通过的表单控件的位置

HTML5都有哪些新的表单属性

javascript对象

SpringBoot中表单提交报错“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported“(代码片段

细说 Form (表单)

vue elementui el-form rules动态验证的实例代码详解