集中我的表单中的一些错误消息



目前,我正在使用errorPlacement为每个输入打印错误消息:

$('#my_form').validate({
errorPlacement: function(error, element) {
// Some code that print error below each inputs
},
...

然后,我尝试用showErrors集中错误消息,如下所示:

showErrors: function(errorMap, errorList) {
// Some code that centralize each error for each input in one place
},
...
});

它工作正常,除了现在我只想集中我的表单的一些错误消息,而不是全部。就像仅将showErrors用于我想要集中的输入,然后errorPlacement用于其他输入。

就像只对我想要集中的输入使用showErrors,然后对其他输入使用errorPlacement

一个将永远超越另一个。

您必须对所有内容使用showErrors,检查errorMaperrorList,并有条件地将每条消息放置在需要的位置。

你可以在 css 中使用 text-align:center; 属性。

相关内容

最新更新