email1: {
required: true,
blacklist: true,
beanEmailValidator: true,
minlength: 6,
maxlength: 70,
remote: {
type: "GET",
url: llbFieldValJSONURL,
data: {
fieldData : function() {
return $("#enterEmail").val();
}
},
dataType:"json",
dataFilter: function(data) {
var json = jQuery.parseJSON(data);
if(json.error == "true") {
return """ + json.errorMessage + """;
} else {
return success;
}
}
}
}
This function check the uniqueness of a username and returns an error if not unique. The issue is that the remote method won't make any additional calls after being valid.. I need it to trigger every time a value is entered/changed.
For example, if I enter 3 non-unique usernames, the call is made every time. If I enter a unique username, the call is made correctly and the username comes back as valid. So the field is then valid. Now if I enter another non-unique (invalid) username, the remote method won't trigger again.
Wondering if it's somehow caching the response?
invalid (non-unique) response:
{"error":"true","errorMessage":"<b>The User Name you chose is already in use.</b> Please enter another name."}
valid (unique) response:
{"error":"false","errorMessage":""}
Edit
Saw this on SO:
https://stackoverflow.com/a/1821667/335514
$("#site").change(function() {
$("#email").removeData("previousValue");
});
So the plugin seems to be caching the response. Does the plugin have a method to switch off caching, or would adding a cache: false
to the ajax call do the same thing?
Edit
Neither of these methods worked. It appears that once a field is marked valid, it won't make the remote call again. Thoughts on how to fix? Would putting the function into it's own addMethod prevent this scenario?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…