I am trying to ignore a "remote" validation property for a form using jQuery validation plugin, so I can enable it when the form is submitted instead of an onBlur of a field. I have the following code, but am getting a syntax error. How can I fix it?
$(document).ready(function()
{
$("#checkNameForm").validate( {
"onkeyup":false,
"rules":{
"Name":{
"required":true,
"minlength":5,
"maxlength":10,
"remote":"\/abc\/def\/checkname"
}
},
"messages":{
"Name":{
"required":"Please enter a Name.",
"remote":"Name is already in use."
}
},
"ignore":"input[
remote
] ",
success:function(label) {
label.addClass("success");
},
"validClass":"success"
} );
});
Having line breaks inside of the ignore option is the issue:
$(document).ready(function()
{
$("#checkNameForm").validate( {
onkeyup: false,
rules: {
"Name": {
"required":true,
"minlength":5,
"maxlength":10,
"remote":"\/abc\/def\/checkname"
}
},
messages: {
"Name": {
"required":"Please enter a Name.",
"remote":"Name is already in use."
}
},
ignore: "input[remote]",
success: function(label) {
label.addClass("success");
},
"validClass":"success"
} );
});
您可以使用这种更简单的方法从元素中删除远程验证: $('#myfield').rules('remove', 'remote');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.