jqeury validate(2): 将校验规则写到js代码中
2013-04-25 14:58
232 查看
required:true
必须有值
required:"#aa:checked"表达式的值为真,则需要验证
required:function(){}返回为真,表时需要验证
后边两种常用于,表单中需要同时填或不填的元素
必须有值
required:"#aa:checked"表达式的值为真,则需要验证
required:function(){}返回为真,表时需要验证
后边两种常用于,表单中需要同时填或不填的元素
<!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> <title>将校验规则写到控件中</title> <script src="jqValidate/jquery.min.js" type="text/javascript"></script> <script src="jqValidate/jquery.metadata.js" type="text/javascript"></script> <script src="jqValidate/jquery.validate.js" type="text/javascript"></script> <script src="jqValidate/jquery.validate.messages_cn.js" type="text/javascript"></script> <script type="text/javascript"> //1. messages处,如果某个控件没有message,将调用默认的信息 $(function () { $("#signupForm").validate({ rules: { firstname: "required", email: { required: true, email: true }, password: { required: true, minlength: 5 }, confirm_password: { required: true, minlength: 5, equalTo: "#password" } }, messages: { firstname: "请输入姓名", email: { required: "请输入Email地址", email: "请输入正确的email地址" }, password: { required: "请输入密码", minlength: jQuery.format("密码不能小于{0}个字 符") }, confirm_password: { required: "请输入确认密码", minlength: "确认密码不能小于5个字符", equalTo: "两次输入密码不一致不一致" } } }); }); </script> </head> <body> <form id="signupForm" method="get" action=""> <p> <label for="firstname"> Firstname</label> <input id="firstname" name="firstname" /> </p> <p> <label for="email"> E-Mail</label> <input id="email" name="email" /> </p> <p> <label for="password"> Password</label> <input id="password" name="password" type="password" /> </p> <p> <label for="confirm_password"> 确认密码</label> <input id="confirm_password" name="confirm_password" type="password" /> </p> <p> <input class="submit" type="submit" value="Submit" /> </p> </form> </body> </html>
相关文章推荐
- jQuery EasyUI---validatebox 校验规则扩展
- jQuery插件EasyUI校验规则 validatebox验证框
- easyui ValidateBox validType字段设置多个校验规则
- jQuery Validate 表单验证插件----通过name属性来关联字段来验证,改变默认的提示信息,将校验规则写到 js 代码中
- 自定义easy-ui validatebox 如maxLength()等等校验规则
- jquery.validate动态更改校验规则 【转】
- jquery.validate动态更改校验规则
- 使用jquery.validate.min.js插件进行表单验证并自定义校验规则
- jQuery 切换radio 改变validateRule的校验规则
- 自定义jQValidate校验规则
- jQuery插件EasyUI校验规则 validatebox验证框
- 为validate.js添加新的校验规则
- jQuery EasyUI---validatebox 校验规则扩展
- jQuery Validate 验证,校验规则写在控件中的具体实例
- jquery validate 插件:(3)校验规则
- jQuery Validate(2) - 默认、自定义校验规则与提示
- jQuery EasyUI---validatebox 校验规则扩展
- 自定义easy-ui validatebox 如maxLength()等等校验规则
- 自定义easy-ui validatebox 如maxLength()等等校验规则
- jQuery Validate 验证,校验规则写在控件中的具体例子