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<script src= ". /.. /scripts/jquery-1.3.1.js "type=" Text/javascript "></script>7<script src= "Lib/jquery.validate.js" type= "Text/javascript" ></script>8<style type= "Text/css" >9* {Font-family:verdana; font-size:96%; }Tenlabel {width:10em;float: Left;} OneLabel.error {float: none; color:red; Padding-left:. 5em; vertical-align:top;} A p {clear:both;} -. Submit {margin-Left:12em;} - theem {font-weight:bold; padding-right:1em; vertical-align:top;} - Em.error { -Background:url ("Images/unchecked.gif") no-repeat 0px 0px; -padding-left:16px; + } - em.success { +Background:url ("Images/checked.gif") no-repeat 0px 0px; Apadding-left:16px; at } - -</style> -<script type= "Text/javascript" > -$ (document). Ready (function(){ - in$ ("#commentForm"). Validate ({ - rules: { to Username: { +Requiredtrue, -Minlength:2 the }, * Email: { $Requiredtrue,Panax NotoginsengEmailtrue - }, theURL: "url", +Comment: "Required" A }, the + messages: { - Username: { $Required: ' Please enter your name ', $MinLength: ' Please enter at least two characters ' - }, - Email: { theRequired: ' Please enter e-mail ', -Email: ' Please check the format of email 'Wuyi }, theURL: ' Please check the format of the URL ', -Comment: ' Please enter your comment ' Wu }, - AboutErrorelement: "em",//you can use other tags, remember to change the style as well $Successfunction(label) { - //Label pointing to the above error message label EM -Label.text ("")//Empty the error prompt message -. addclass ("Success");//Add a custom success class A } + the }); - $ }); the</script> the the the<body> - in the<form class= "Cmxform" id= "Commentform" method= "Get" action= "" > the<fieldset> About<legend> a simple validation with validation tips For example of comments </legend> the<p> the<label for= "Cusername" > Name </label> the<em>*</em><input id= "Cusername" name= "username" size= "/>" +</p> -<p> the<label for= "Cemail" > Email </label>Bayi<em>*</em><input id= "Cemail" name= "email" size= "/>" the</p> the<p> -<label for= "curl" > URL </label> -<em> </em><input id= "curl" name= "url" size= "value=" "/> the</p> the<p> the<label for= "Ccomment" > Your comments </label> the<em>*</em><textarea id= "ccomment" name= "comment" cols= "All" rows= "2" ></textarea> -</p> the<p> the<input class= "Submit" type= "Submit" value= "Submission"/> the</p>94</fieldset> the</form> the</body> the
:
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<script src= ". /.. /scripts/jquery-1.3.1.js "type=" Text/javascript "></script>7<script src= "Lib/jquery.validate.js" type= "Text/javascript" ></script>8<style type= "Text/css" >9* {Font-family:verdana; font-size:96%; }Tenlabel {width:10em;float: Left;} OneLabel.error {float: none; color:red; Padding-left:. 5em; vertical-align:top;} A p {clear:both;} -. Submit {margin-Left:12em;} - theem {font-weight:bold; padding-right:1em; vertical-align:top;} - Em.error { -Background:url ("Images/unchecked.gif") no-repeat 0px 0px; -padding-left:16px; + } - em.success { +Background:url ("Images/checked.gif") no-repeat 0px 0px; Apadding-left:16px; at } - -</style> -<script type= "Text/javascript" > -$ (document). Ready (function(){ - in //Customizing a validation method - $.validator.addmethod ( to"Formula",//Verify method Name + function(value, element, param) {//validation rules - returnValue = =eval (param); the }, *' Please enter the results of the mathematical formula correctly. '//Validation Prompt Information $ );Panax Notoginseng -$ ("#commentForm"). Validate ({ the rules: { + Username: { ARequiredtrue, theMinlength:2 + }, - Email: { $Requiredtrue, $Emailtrue - }, -URL: "url", theComment: "Required", - Valcode: {WuyiFormula: "7+9" the } - }, Wu - messages: { About Username: { $Required: ' Please enter your name ', -MinLength: ' Please enter at least two characters ' - }, - Email: { ARequired: ' Please enter e-mail ', +Email: ' Please check the format of email ' the }, -URL: ' Please check the format of the URL ', $Comment: ' Please enter your comment ' the }, the theErrorelement: "em",//used to create error message labels theSuccessfunction(label) {//callback function for validation after successful execution - //Label pointing to the above error message label EM inLabel.text ("")//Empty the error prompt message the. addclass ("Success");//Add a custom success class the } About the the }); the + }); -</script> the Bayi the<body> the - -<form class= "Cmxform" id= "Commentform" method= "Get" action= "" > the<fieldset> the<legend> a simple validation with validation tips For example of comments </legend> the<p> the<label for= "Cusername" > Name </label> -<em>*</em><input id= "Cusername" name= "username" size= "/>" the</p> the<p> the<label for= "Cemail" > Email </label>94<em>*</em><input id= "Cemail" name= "email" size= "/>" the</p> the<p> the<label for= "curl" > URL </label>98<em> </em><input id= "curl" name= "url" size= "value=" "/> About</p> -<p>101<label for= "Ccomment" > Your comments </label>102<em>*</em><textarea id= "ccomment" name= "comment" cols= "></textarea>"103</p>104<p> the<label for= "Cvalcode" > Verification Code </label>106<input id= "Cvalcode" name= "Valcode" size= "value="/>=7+9107</p>108<p>109<input class= "Submit" type= "Submit" value= "Submission"/> the</p>111</fieldset> the</form>113</body> the
:
jquery Validate use