jquery form Validation

Source: Internet
Author: User
Tags jquery form validation

<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">"http://www.w3.org/1999/xhtml">"Content-type"Content="text/html; Charset=utf-8"/><title></title><style type="Text/css">Body {font:12px/19px Arial, Helvetica, Sans-serif; color:#666;} Form Div {margin:5px0;}.intLabel {float: Left; width:100px; text-align:right;}.intinput {padding:1px 1px; border:1px solid #ccc; height:16px;}. Sub {padding-left:100px;}. Sub input {margin-right:10px;}. formtips{width:200px;margin:2px;padding:2px;}. onerror{background: #FFE0E9 URL (../img/reg3.gif) no-repeat0Center; Padding-left:25px;}. onsuccess{background: #E9FBEB URL (../img/reg4.gif) no-repeat0Center; Padding-left:25px;}. high{color:red;}</style><!--The introduction of jquery--><script src=".. /scripts/jquery-1.3.1.js"Type="Text/javascript"></script><script type="Text/javascript">//<! [Cdata[$ (function () {//if it is required, add the Red Star logo.$("form:input.required"). each (function () {var$required = $ ("<strong class= ' High ' > *</strong>");//Creating Elements$( This). Parent (). append ($required);//and append it to the document.       }); //after the text box loses focus$('Form:input'). blur (function () {var$parent = $ ( This). parent (); $parent. Find (". Formtips"). Remove (); //Verify user name            if( $( This). is('#username') ){                   if( This. value==""|| This. value.length <6 ){                       varErrorMsg ='Please enter a user name of at least 6 digits.'; $parent. Append ('<span class= "Formtips onError" >'+errormsg+'</span>'); }Else{                       varOkmsg ='input is correct.'; $parent. Append ('<span class= "Formtips onsuccess" >'+okmsg+'</span>'); }            }            //Verifying Messages            if( $( This). is('#email') ){               if( This. value==""|| ( This. value!=""&&!/[email protected]+\. [A-za-z] {2,4}$/.test ( This. Value)) ){                     varErrorMsg ='Please enter the correct e-mail address.'; $parent. Append ('<span class= "Formtips onError" >'+errormsg+'</span>'); }Else{                     varOkmsg ='input is correct.'; $parent. Append ('<span class= "Formtips onsuccess" >'+okmsg+'</span>'); }}). KeyUp (function () {$ ( This). Triggerhandler ("Blur"); }). focus (function () {$ ( This). Triggerhandler ("Blur"); });//End Blur//submit, final verification. $('#send'). Click (function () {$ ("form:input.required"). Trigger ('Blur'); varNumerror = $ ('form. OnError'). length; if(numerror) {return false; } alert ("registration is successful, the password has been sent to your mailbox, please check.");       }); // Reset$('#res'). Click (function () {$ (". Formtips"). Remove (); });})//]]></script>"Post"action=""> <divclass="int"> <label for="username"> User name:</label> <input type="text"Id="username" class="Required"/> </div> <divclass="int"> <label for="Email"> Email:</label> <input type="text"Id="Email" class="Required"/> </div> <divclass="int"> <label for="Personinfo"> Personal Information:</label> <input type="text"Id="Personinfo"/> </div> <divclass="Sub"> <input type="Submit"Value="Submit"Id="Send"/><input type="Reset"Id="Res"/> </div></form></body>

jquery form Validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.