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

2020-12-17  本文已影响0人  黎凡s

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

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

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

猜你喜欢

热点阅读