首页 > 代码库 > 对form进行验证
对form进行验证
//对form表单name属性输入框进行验证,里面定义规则
//rules 表示验证的规则, messages是验证不通过的提示信息
rules: {
user:{
required: true,
minlength: 6
},
upassword:{
required: true,
minlength: 6
},
equalPwd: {
required: true,
minlength: 6,
equalTo:‘#upassword‘
},
email:{
required: true,
email: true
},
money:{
required: true,
number: true
}
},
messages:{
user:{
required: "用户名不能为空",
minlength: "用户名的长度不能少于6个字符"
},
upassword:{
required: "密码不能为空",
minlength: "密码的长度不能小于6个字符"
},
equalPwd: {
required: "确认密码不能为空",
minlength: "确认密码的长度不能小于6个字符",
equalTo:‘两次输入的密码不一致‘
},
email:{
required: "邮箱不能为空",
email: "邮箱的格式不正确"
},
money:{
required: "金额不能为空",
number: "金额必须合法,是一个数字型值"
}
}
对form进行验证