我在输入Html元素中有一个表单:
<input name="MyInputName" type="number" />并且它的'type'属性设置为“number”,因为我想利用HTML5的功能。
在我的js代码中,我初始化jQuery.validate插件:
$('.myFormClassName').validate({ rules: { MyInputName: { digits: true } } });...但它不起作用..我已经正确管理了所有内容:我确信这是因为如果我从输入的'type'属性中取消(或将其设置为“text”),则验证工作正常。
这是jQuery.validate插件的错误还是我不小心错过了一些重要的东西?
感谢大家 ;)
I've got a form, within an input Html element:
<input name="MyInputName" type="number" />and its 'type' attribute is set to "number" because I want to take advantage of HTML5's features.
In my js code I initialize jQuery.validate plugin:
$('.myFormClassName').validate({ rules: { MyInputName: { digits: true } } });... but it does not work.. I've managed everything correctly: I'm sure of this because if I get off my input's 'type' attribute (or set it to "text"), the validation works fine.
Is it a bug of jQuery.validate plugin or am I carelessly missing something important?
Thanks everyone ;)
最满意答案
此问题之前已经确定,并且据称已修复......
你可以在这里阅读: https : //github.com/jzaefferer/jquery-validation/issues/97和这里: https : //github.com/jzaefferer/jquery-validation/pull/145
然而,似乎其他人最近报道(上述“修复”大约是2年,而本期报告是在过去的几个月内),所以它可能会再次被打破: https : //github.com/jzaefferer/ jQuery的验证/问题/ 922
我发现的唯一解决方法是在input元素上使用type="text" 。 这是不幸的,因为那样你最终得到纯文本输入而不是漂亮的HTML5整数框。
This issue has been identified before and was supposedly fixed...
You can read about it here: https://github.com/jzaefferer/jquery-validation/issues/97 and here: https://github.com/jzaefferer/jquery-validation/pull/145
However, it appears others are reporting more recently (the above "fix" is around 2 years old, whereas this issue report is within the past few months) and so it may be broken again: https://github.com/jzaefferer/jquery-validation/issues/922
The only work-around I've found is to use type="text" on the input element. This is unfortunate because then you end up with the plain text input rather than the nice HTML5 integer box.
更多推荐
发布评论