AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > PHP编程

jquery.validate.js和jquery.metadata.js的例子

51自学网 2016-09-19 http://www.wanshiok.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>jquery validate表单验证插件制作注册表单验证提交</title><meta name="description" content="jquery validate表单验证插件制作用户注册页面表单提交验证,用户名、手机、密码、邮箱等表单验证。通过这款validate表单验证插件能制作多种表单提交验证。" /><script language="javascript" type="text/javascript" src="http://red-apple.blog.163.com/blog/js1/jquery.js"></script><script language="javascript" type="text/javascript" src="http://red-apple.blog.163.com/blog/js1/jquery.validate.js"></script><!--<script language="javascript" type="text/javascript" src="http://red-apple.blog.163.com/blog/js1/jquery.metadata.js"></script>--><script type="text/javascript">$(document).ready(function(){    $("#signupForm").validate({        rules: {            "firstname":{                required: true,                rangelength: [4, 20]            },            "email":{                required: true,                email:true            },            "password":{                required: true,                rangelength: [4, 20]            },            "confirm_password":{                required: true,                equalTo: "#password"            }        },        messages: {            "firstname":{                required: "请输入用户名",                rangelength: "请输入4-20位字母开头的字母或数字和下划线"            },            "email":{                required:"请输入邮箱地址",                email:"请输入正确的email地址"            },            "password":{                required:"请输入密码",                rangelength: "请输入4-20位字母开头的字母或数字和下划线"            },            "confirm_password":{                required:"请再次输入密码",                equalTo:"两次输入密码不一致",            }        }    });});</script></head><body><form id="signupForm" method="post" action="">    <table width="100%">        <tr>            <td class="tdcon">用户名:</td>            <td>                <input type='text' name="firstname" id="firstname" value="" />                <div class="tipinfo"></div>            </td>        </tr>        <tr>            <td class="tdcon">邮箱:</td>            <td>                <input type='text' name="email" id="email" value="" />                <div class="tipinfo"></div>            </td>        </tr>        <tr>            <td class="tdcon">密码:</td>            <td>                <input type='text' name="password" id="password" value="" />                <div class="tipinfo"></div>            </td>        </tr>        <tr>            <td class="tdcon">确认密码:</td>            <td>                <input type='text' name="confirm_password" id="confirm_password" value="" />                <div class="tipinfo"></div>            </td>        </tr>        <tr>            <td></td>            <td><button name="Submit" type="submit">同意以下服务条款并注册</button></td>        </tr>    </table></form></body></html>
上面的代码不能使用jquery.metadata.js,
如果用的话就可以在class属性里面设置设置规则 如:
class="{required:true,minlength:5,messages:{required:'请输入内容'}}"
class="{required:true,minlength:5,equalTo:'#password'}"


说明
:本教程来源互联网或网友上传或出版商,仅为学习研究或媒体推广,wanshiok.com不保证资料的完整性。
 
上一篇:Jquery表单提交插件jquery form的用法  下一篇:jQuery遍历节点-find()方法使用说明