jquery form Validation

Source: Internet
Author: User
Tags jquery form validation

1<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title></title>6<link href= "Css/style.css" rel= "stylesheet" type= "Text/css"/>7<!--introducing jquery--8<script src= ". /scripts/jquery-1.3.1.js "type=" Text/javascript "></script>9<script type= "Text/javascript" >Ten //<! [Cdata[ One$(function(){ A   //if it is required, add the Red Star logo. -$ ("form:input.required"). each (function(){ -    var$required = $ ("<strong class= ' High ' > *</strong>");//Creating Elements the$( 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 A     if( $( This). is (' #username ') ){ at      if( This. value== "" | | This. value.length < 6 ){ -          varerrormsg = ' Please enter a user name of at least 6 bits. '; -$parent. Append (' <span class= ' formtips onError ' > ' +errormsg+ ' </span> '); -}Else{ -          varokmsg = ' input correct. '; -$parent. Append (' <span class= ' formtips onsuccess ' > ' +okmsg+ ' </span> '); in      } -     } to     //Verifying Messages +     if( $( This). is (' #email ') ){ -     if( This. value== "" | | ( This. value!= "" && ) ) ){ the                       varerrormsg = ' Please enter the correct e-mail address. '; *$parent. Append (' <span class= ' formtips onError ' > ' +errormsg+ ' </span> '); $}Else{Panax Notoginseng                       varokmsg = ' input correct. '; -$parent. Append (' <span class= ' formtips onsuccess ' > ' +okmsg+ ' </span> '); the     } +     } A}). KeyUp (function(){ the$( This). Triggerhandler ("Blur"); +}). Focus (function(){ -$( This). Triggerhandler ("Blur"); $});//End Blur $  -    -   //submit, final verification.  the$ (' #send '). Click (function(){ -$ ("form:input.required"). Trigger (' blur '));Wuyi     varNumerror = $ (' form. OnError '). length; the     if(numerror) { -      return false; Wu     }  -Alert ("Registration is successful, password has been sent to your mailbox, please check.")); About    }); $  -   // Reset -$ (' #res '). Click (function(){ -$ (". Formtips"). Remove ();  A    }); + }) the //]]> -</script> $ the<body> the  the<form method= "POST" action= "" > the<div class= "int" > -<label for= "username" > Username:</label> in<input type= "text" id= "username" class= "required"/> the</div> the<div class= "int" > About<label for= "email" > Email:</label> the<input type= "text" id= "email" class= "required"/> the</div> the<div class= "int" > +<label for= "Personinfo" > Profile:</label> -<input type= "text" id= "Personinfo"/> the</div>Bayi<div class= "Sub" > the<input type= "Submit" value= "commit" id= "send"/><input type= "reset" id= "res"/> the</div> -</form> -  the</body> the

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.