Is is possible to to have a depends on a jQuery remote validation?
- by David Kethel
I am using jQuery remote validation to check if the description is already being used.
Description: {
required: true,
maxlength: 20,
remote: function () {
var newDescription = $("#txtDescription").val();
var dataInput = { geoFenceDescription: newDescription };
var r = {
type: "POST",
url: "/ATOMWebService.svc/DoesGeoFenceDescriptionExist",
data: JSON.stringify(dataInput),
contentType: "application/json; charset=utf-8",
dataType: "json",
dataFilter: function (data) {
var x = (JSON.parse(data)).d;
return JSON.stringify(!x);
}
};
return r;
}
},
The problem I have is that this remote validation occurs when the user has NOT modified the text box and comes back saying the description has been used because it found it self in the database.
So is it possible to only run the remote validation if the text field is different to what was originally in it?
I noticed the the jQuery required validation has a depends option, but I couldn't get it to work with the remote call.