我试图找出如何使parsleyjs只触发验证的模糊对于具有场已经验证失败。
参见http://jsfiddle.net/billyroebuck/zbmv2d3w/
标记:
<form id="myform">
<label for="email">Email</label>
<input type="email" name="email"
data-parsley-required="true"
data-parsley-type="email"
data-parsley-custom
data-parsley-trigger="blur"
/>
<input type="submit" />
</form>
JavaScript:
window.Parsley.addValidator('custom',
function (value, requirement) {
console.log('custom validation triggered');
sleepFor(3000); // simulate a delay (testing only)
if (value == '[email protected]') {
console.log('custom validation failed');
return false;
}
console.log('custom validation passed');
return true;
}, 32)
.addMessage('en', 'custom', 'custom validation failed');
$('#myform').parsley();
function sleepFor(sleepDuration) {
console.log('pretend this takes a while...');
var now = new Date().getTime();
while (new Date().getTime() < now + sleepDuration) { /* do nothing */
}
}
parsleyjs版本2.2.0-rc1
电子邮件字段具有验证规则以检查:
我将此字段的parsley-trigger属性设置为模糊。
脚步:
如何确保仅在模糊事件的无效字段上触发了验证?
提前致谢!
恐怕目前没有这样的选择。想法是尽快删除错误消息,并且每个人似乎都喜欢这样。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句