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

当input的type设置为number的时候,要对这个input进行是否为数值验证失效 #228

Closed
lxcsmallcity opened this Issue Apr 13, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@lxcsmallcity
Copy link

lxcsmallcity commented Apr 13, 2016

当前脚本的版本信息:
/*! nice Validator 0.8.0

问题描述:
当input的type设置为number的时候,要对这个input进行是否为数值验证失效,只能提示"不能为空",如果在这个input输入英文字符的时候,依然提示"不能为空"。将input的type改为text验证正常。
为了在移动设备上可以更方便的输入数字(弹出数字键盘),所以才会将input的type设为number。
测试html代码
`


数量:

`

测试zh_CN.js配置
$.validator.config({ stopOnError: true, //focusCleanup: true, theme: 'yellow_top', msgStyle: "float:left;z-index:999", timely: 2, defaultMsg: "{0}格式不正确", loadingMsg: "正在验证...",

顺便提到一个“msgStyle: "float:left;z-index:999",”这个配置,因为我是在bootstrap3.3.6中使用您这个验证插件,并且又用到了input-group这个效果,如果没有加上msgStyle这个配置,会导致验证提示位置不正常。

@niceue

This comment has been minimized.

Copy link
Owner

niceue commented May 6, 2016

因为 number 类型的 input 输入非数字的时候,实际上是没有值的吧
话说是什么手机?number 类型还可以输入字母?

@niceue niceue added the tracking label May 8, 2016

@niceue niceue closed this in dfc376d May 9, 2016

@niceue niceue added bug and removed tracking labels May 9, 2016

@niceue niceue added this to the 1.0.0 milestone May 10, 2016

@lxcsmallcity

This comment has been minimized.

Copy link
Author

lxcsmallcity commented May 11, 2016

恩恩,不好意思,之前没了解到input设置为number的时候,输入英文字母的时候,取值的结果是空,所以提示为空也是没错,不过对于普通用户来说,这样的UI有点不太友好。(他们会想:“我明明有输入东西了,为什么还提示不能为空”)。

至于说input设置为number的时候,在电脑端的浏览器是可以输入任何字母,在手机端只能输入英文字母"e",因为可以存在指数的数值"1.3e5"

@niceue

This comment has been minimized.

Copy link
Owner

niceue commented May 11, 2016

nice-validator 1.0.0 修复了这个问题

@lxcsmallcity

This comment has been minimized.

Copy link
Author

lxcsmallcity commented May 11, 2016

谢谢

@niceue niceue added improve and removed bug labels Aug 11, 2016

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