I am using jQuery remote validation to verify that the description is already in use.
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 is that this remote check occurs when the user has NOT modified the text field and returns saying that the description was used because it found it in the database.
So, is it possible to run remote verification only if the text field is different from what was originally in it?
I noticed that the required jQuery validation has a "depend" option, but I could not get it to work with a remote call.
source share