我正在尝试使用 formvalidation.io 验证 10 个表单字段。如果 10 个验证中的任何一个失败,我需要返回 false。但是,要访问验证是否已通过,您需要调用一个 Promise。
var otherFacilityFields = [
"addressLine1",
"city"
];
fieldsPass = otherFacilityFields.every(function(field) {
fv.validateField(field).then(function(status) {
if (status != 'Valid') {
return false;
}
return true;
});
});
以上不起作用,因为承诺不是同步的。