Home >Web Front-end >JS Tutorial >jQuery Validate form validation plug-in adds verification in the form of class attribute_jquery
The example in this article introduces the jQuery Validate form verification plug-in, adding verification in the form of class attributes, and shares it with everyone for your reference. The specific content is as follows
The effect is as follows:
1. jQuery form validation plug-in, add verification in the form of class attribute
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery表单验证插件----添加class属性形式的校验</title> <script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script> <script src="lib/jquery.validate.js" type="text/javascript"></script> <style type="text/css"> * { font-family: Verdana; font-size: 96%; } label { width: 10em; float: left; } label.error { float: none; color: red; padding-left: .5em; vertical-align: top; } p { clear: both; } .submit { margin-left: 12em; } em { font-weight: bold; padding-right: 1em; vertical-align: top; } </style> <script type="text/javascript"> $(document).ready(function(){ $("#commentForm").validate(); }); </script> </head> <body> <form class="cmxform" id="commentForm" method="get" action=""> <fieldset> <legend>jQuery表单验证插件----添加class属性形式的校验</legend> <p> <label for="cusername">姓名</label> <em>*</em><input id="cusername" name="username" size="25" class="required" minlength="2" /> </p> <p> <label for="cemail">电子邮件</label> <em>*</em><input id="cemail" name="email" size="25" class="required email" /> </p> <p> <label for="curl">网址</label> <em> </em><input id="curl" name="url" size="25" class="url" value="" /> </p> <p> <label for="ccomment">你的评论</label> <em>*</em><textarea id="ccomment" name="comment" cols="22" class="required"></textarea> </p> <p> <input class="submit" type="submit" value="提交"/> </p> </fieldset> </form> </body> </html>
2. Default rules
Default verification rules:
The above is the entire content of this article, I hope it will be helpful to everyone’s study.