Skip to content

Instantly share code, notes, and snippets.

@youzipi
Created September 13, 2016 01:40
Show Gist options
  • Save youzipi/c0e147957c747638a8604d863317c230 to your computer and use it in GitHub Desktop.
Save youzipi/c0e147957c747638a8604d863317c230 to your computer and use it in GitHub Desktop.
jquery.validate
$("#newCustomerForm").validate({
submitHandler: function (form) {
form.submit();
},
errorPlacement: function (error, element) {
error.appendTo(element.parents('.form-group'));
},
rules:{
customerUsername: {
isMobile:true,
remote: {
url: "checkbossmobileexist.htm",
type: "post",
data: {
mobile: function() {
return $( "#customerUsername" ).val();
}
},
dataFilter: function(data, type) {
console.log(data);
console.log(type);
return data == 0;
},
// success: function (data) {
// return data > 0;
// }
}
}
},
messages: {
customerUsername:{
remote:"该手机号已注册"
},
// newAgentProvince: {
// required: "省份不能为空"
// },
// newAgentCity: {
// required: "城市不能为空"
// },
// newAgentCounty: {
// required: "区县不能为空"
// },
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment