我有以下驗證設置的一種形式:嘗試設置自定義的驗證消息的jQuery遠程
$('#form').validate({
onfocusout: false,
onkeyup: false,
onclick: false,
success: function(){
$('#username').addClass('input-validation-confirmation');
}
});
$('#username').rules("add", {
onfocusout: false,
onkeyup: false,
required: true,
email: true,
remote: {
url: function,
type: 'GET',
dataType: 'json',
traditional: true,
data: {
username: function() {
return $('#username').val();
}
},
dataFilter: function (responseString) {
var response = jQuery.parseJSON(responseString);
currentMessage = response.Message;
if (response.State == 0) {
currentMessage = currentMessage + 0;
return false;
}
return 'true';
},
beforeSend: function (response) {
showLoadingIndicator($('#username'));
},
complete: function() {
hideLoadingIndicator($('#username'));
}
}
});
什麼,這是試圖做的是使用相同的驗證元素(爲了與其他一些工作框架)顯示錯誤和成功方法。
我的問題是,我的統治的成功方法被炒魷魚之前,在遠程驗證已完成。我嘗試了幾種方式設置消息,但自定義消息參數似乎沒有在驗證成功時調用。
是否使用遠程和模式驗證規則的混合時,任何人都知道的其他方法使用驗證錯誤場成功和錯誤信息?
編輯:
現在我明白我是在錯誤的時間期待一個成功的事件。我需要在驗證完成後觸發的事件(未提交)。有沒有這樣的事件?
我假設你使用http://jqueryvalidation.org/?如果是這樣,它看起來像[遠程方法](http://jqueryvalidation.org/remote-method)是基於每個字段的,並且應該是要觸發遠程檢查的字段的子節點。 。 。 – ernie