I am validating a field remotely and I am getting the following error:
Uncaught TypeError: Cannot read property 'call' of undefined.
jquery.validate.js:617
n.extend.checkjquery.validate.js:423
n.extend.elementjquery.validate.js:271
n.extend.defaults.onfocusoutjquery.validate.js:366
ijquery.validate.js:1359
(anonymous function)jquery-2.0.3.js:4676
i.event.dispatchjquery-2.0.3.js:4360
i.event.add.y.handlejquery-2.0.3.js:4594
i.event.triggerjquery-2.0.3.js:4893
i.event.simulatejquery-2.0.3.js:5009
i.support.focusinBubbles.i.each.f
Here is my code:
$("input[id$=txtCompanyName]").rules("add", {
required: true,
alphanumeric: true,
remote: function() {
return {
url: "/Resources/wsResources.asmx/IsCompanyAvailable",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ company: $("input[id$=txtCompanyName]").val() }),
dataFilter: function(data) {
console.log(data);
var msg = JSON.parse(data);
if (msg.hasOwnProperty('d'))
return msg.d;
else
return msg;
}
};
},
messages: {
required: "This field is required",
alphanumeric: "Company name is not in correct format",
remote: $.validator.format("{0} already exists")
}
});