jQuery validate使用
$("#form-add").validate({
rules:{
name:{
required:true,
minlength: 2,
maxlength: 20,
remote: {
url: rootPath + "/CourseController/checkNameUnique",
type: "post",
dataType: "json",
dataFilter: function(data, type) {
if (data == "0")
return true;
else
return false;
}
}
},
price:{
required:true,
number:true
},
fileName:{
required:true,
maxlength:20
}
},
messages: {
"name": {
remote: "已经存在"
}
},
submitHandler:function(form){
add();
}
});