JS Verification code is as follows: (need to introduce two JS packets)
1 <Scripttype= "Text/javascript"src= "/js/jquery.validate.min.js"></Script>2 <Scripttype= "Text/javascript"src= "/js/jquery-1.7.2.js"></Script>3 <Scripttype= "Text/javascript">4 functionValidatecartoon () {5 varname= $("#txtCompany"). Val (). Trim ();6 if(Name==""){7 Alert ("Company/organization name cannot be empty! ");8 return false;9 }Ten varMobile= $("#txtName"). Val (). Trim (); One if(Mobile==""){ A Alert ("the name cannot be empty! "); - return false; - } the varEmail=$("#txtEmail"). Val (). Trim (); - varpattern= /^ ([\.a-za-z0-9_-]) [email protected] ([a-za-z0-9_-]) + (\.[ a-za-z0-9_-]) +/; - if(Email==""){ - Alert ("The mailbox cannot be empty"); + return false; - } + if (!pattern.test (email)) { A Alert ("Please enter the correct email address. "); at return false; - } - varMobile= $("#txtPhone"). Val (). Trim (); - varStr=/^ ((1[3|5|7|8][0-9]{1}) +\d{8}) $/; - if(Mobile==""){ - Alert ("the contact number cannot be empty! "); in return false; - } to Else if(!Mobile.match (str)) { + Alert ("Please enter the correct 11-digit phone number! "); - return false; the } * $ return true;Panax Notoginseng - } the </Script>View Code
. NET code is as follows:
1<form id="Form1"runat="Server">2<div>3<div> contact information is as follows:</div>4<dl>5<dt> <spanclass='cRed'>*</span> Company/unit name (required) </dt>6<dd><asp:textbox id="Txtcompany"runat="Server"></asp:TextBox></dd>7</dl>8<dl>9<dt><spanclass='cRed'>*</span> name (required) </dt>Ten<dd><asp:textbox id="txtname"runat="Server"></asp:TextBox></dd> One</dl> A<dl> -<dt><spanclass='cRed'>*</span> Email address (required, check email format) </dt> -<dd><asp:textbox id="Txtemail"runat="Server"></asp:TextBox></dd> the</dl> -<dl> -<dt> Phone (optional) </dt> -<dd><asp:textbox id="Txtphone"runat="Server"></asp:TextBox></dd> +</dl> -<asp:button id="btnsubmit"runat="Server"text="Submit Information"onclientclick="return Validatecartoon ()"onclick="btnSubmit_Click"/> +</div> A</form>
View Code
This can be done as shown in the code above. NET form of JS validation.
. The JS verification of forms in net