New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug of rule "match" with "display" options (match规则与display同用时的bug) #267

RoyceWang opened this Issue Jan 24, 2018 · 0 comments


None yet
2 participants
Copy link

RoyceWang commented Jan 24, 2018

When use rule "match" with a custom display function such as:

"init_value":{rule:"required;integer[+0];match[lte, current_value];"}
return $form.find("label[for='" + + "']").text();

And I defined the message template as "{0} can not be greater than {1}!"
(并且,我定义了match lte的校验消息为"{0}不能大于{1}!")
But the validation failed message will be like:
"Init value can not be greater than Init value!"

I read the source code and found the message process function may have a little bug:
At line 1872 in "nice-validator-1.1.3\src\jquery.validator.js":
me.messages.match[type].replace( '{1}', me._getDisplay( element, field2.display || key ) )

I think it should not to replace the '{1}' token with display text generated from elment with belongs to current element.
It should use the display text generated from the target element. That is:
me.messages.match[type].replace( '{1}', me._getDisplay( elmt2, field2.display || key ) )

@niceue niceue closed this in 7e2bccd Mar 11, 2018

@niceue niceue added the bug label Mar 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment