美文网首页
实现jquery.validate每次只提示第一个错误

实现jquery.validate每次只提示第一个错误

作者: 黎凡s | 来源:发表于2020-12-17 16:17 被阅读0次

版本:jquery.validate 1.18
在errorPlacement中将当前验证对象的错误列表改为当前第一个错误即可

注:errorList不能赋值为空数组,空数组将会导致错误消息正常显示,但验证通过

 $("#formId").validate({
             errorPlacement: function (error, element) {
                    alert(error[0].innerText);
                    this.errorList=[this.errorList[0]];
                    //this.errorList=[];
            }
    });

相关文章

网友评论

      本文标题:实现jquery.validate每次只提示第一个错误

      本文链接:https://www.haomeiwen.com/subject/iocbektx.html