简体   繁体   English

验证输入文本字段敲除验证插件时触发错误的验证消息

[英]Wrong validations messages are triggered when validating input text field knockout validation plugin

I am researching the knockout validator plugin. 我正在研究敲除验证器插件。 I have an input text control in the view: 我在视图中有一个输入文本控件:

Prefix:
<input data-bind = "value: Prefix" />

I am doing some validation on the Prefix observable variable: 我正在对Prefix可观察变量进行一些验证:

Prefix.extend({
            minLength: 3,
            required: true
        });

The validation is working but when I enter one character in the input text box and change the focus the message for required rule is shown, not that for minLength. 验证有效,但是当我在输入文本框中输入一个字符并更改焦点时,将显示所需规则的消息,而不是minLength的消息。 I tried some alternative syntax: 我尝试了一些替代语法:

Prefix.extend({ required: true })
            .extend({ minLength: 3 })

But nothing changes. 但是什么都没有改变。 If I enter the minimum required characters and then delete them one by one, the correct rule messages are triggered (minLength message and required message when no characters are left). 如果我输入了所需的最少字符,然后一一删除,则会触发正确的规则消息(如果没有剩余字符,则显示minLength消息和所需消息)。 I am not very much familiar with javascript and I cannot figure out what am I doing wrong. 我对javascript不太熟悉,无法弄清楚我在做什么错。 Any help will be appreciated. 任何帮助将不胜感激。 Thank You! 谢谢!

Check the version of knockout you're using. 检查您使用的基因剔除的版本。 I ran into this issue and found that I was using knockout 2.0.0, the newest version (2.1.0) seems to fix this issue. 我遇到了这个问题,发现我使用的是淘汰赛2.0.0,最新版本(2.1.0)似乎可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM