I am trying to use Jquery Validate and making a call to a webservice to validate a field. But when I do this I get the Firebug error :
invalid label
{“d”:false}
Here is my code, can anybody help?
$("form").validate({
//errorLabelContainer: $("#divErrors"),
rules: {
txtUserName: {
required: true,
minlength: 4,
maxlength: 20,
remote: function() {
var r = {
type: "POST",
url: "/Services/CDServices.asmx/CheckForUniqueUserName",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{'strUserName':'" + $('input[name="txtUserName"]').val() + "'}"
}
return r;
}
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool CheckForUniqueUserName(string strUserName)
{
return false;
}
In your case you can use dataFilter function to “unwrap” your result, like this: