我有一个表单,我正在尝试首先通过远程调用来验证某个字段以进行必需的验证,然后再通过不同的远程调用来进行警告验证。我在此页面上找到了使用两个带有别名的远程调用的示例:https ://github.com/formvalidation/support/issues/310
然而,这似乎非常简单,当我尝试这个时它不起作用。只有一个远程验证被调用。在没有“别名”的情况下单独使用任一遥控器,但使用“别名”不起作用。我正在使用 formvalidation.io v0.7.0 根据这篇文章应该支持“别名”
我接近这个错误吗?这个“别名”想法不是一个真正的选择吗?任何帮助,将不胜感激。作为一种解决方法,我还在回调验证中尝试了 getJSON,但似乎存在时间问题。
这是我的代码:
//Form validation setup
$form.formValidation({
framework: 'bootstrap',
// Feedback icons
icon: {
valid: 'fa fa-check',
invalid: 'fa fa-remove',
validating: 'fa fa-refresh'
},
fields: {
ctl00$kcMasterPagePlaceHolder$TextBoxCaseNumber: {
trigger: 'blur',
validators: {
notEmpty: {
message: 'Case Number is Required'
},
remote:{
message: 'Case Number does not exist. Please contact XXXXX',
url: function(validator, $field, value) {
return './handlers/ServiceInterface.ashx?apistring=api/case/1234';
},
cache: false,
data: function(validator, $field, value) {
return {
valid: true
};
}
}, // end remote
my_remote:{
alias: "remote",
message: 'Warning: There is already an event for this case on this calendar!',
url: function(validator, $field, value) {
var strArguments = "1234";
return './handlers/ServiceInterface.ashx?apistring=api/event?casenumber=' + strArguments ;
},
cache: false,
data: function(validator, $field, value) {
return {
valid: true
};
}
} // end remote
}
}
// 省略其余字段 ...