集中一些来自我表单的错误消息 [英] Centralize some error messages from my form
问题描述
当前,我正在使用errorPlacement
为每个输入打印错误消息:
Currently, I'm using errorPlacement
to print error message for each input :
$('#my_form').validate({
errorPlacement: function(error, element) {
// Some code that print error below each inputs
},
...
然后,我尝试使用showErrors
集中错误消息,如下所示:
Then, I tried to centralize errors messages with showErrors
, like this :
showErrors: function(errorMap, errorList) {
// Some code that centralize each error for each input in one place
},
...
});
工作正常,除了现在我只想集中我的表单中的一些错误消息,而不是全部集中.像只将showErrors
用于我要集中的输入,然后将errorPlacement
用于其他输入.
It works fine, except that now I would like to centralize only some errors messages of my form, not all of them. Something like using showErrors
only for inputs that I want to centralize, then errorPlacement
for the others.
推荐答案
类似于仅将
showErrors
用于我要集中的输入,然后将errorPlacement
用于其他输入的情况.
Something like using
showErrors
only for inputs that I want to centralize, thenerrorPlacement
for the others.
一个将永远超过另一个.
One will always over ride the other.
您必须对所有内容都使用showErrors
,在其中检查errorMap
和errorList
,并有条件地将每条消息放在需要的地方.
You'll have to use showErrors
for everything, where you inspect the errorMap
and errorList
and conditionally place each message where you need it.
这篇关于集中一些来自我表单的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!