IE11输入类型=数字 [英] IE11 Input type = Number

查看:182
本文介绍了IE11输入类型=数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用angular 4.3,我有一个带有输入类型编号的输入字段.我试图限制用户输入任何字符/字母.但是,不完全支持输入类型编号,它允许我在输入字段中输入诸如"ABCDEFG"之类的字符.限制字母的最佳方法是什么?

I'm working with angular 4.3, I have an input field with input type number. I'm trying to restrict the user from entering any characters/letters. However, input type number is not fully supported and allows me to enter characters such as "ABCDEFG" within the input field. What would be the best approach to restrict letters?

<input type="number"/>

推荐答案

如果number不起作用,我通常建议您使用<input type="text" pattern="\d+"/>.

If number doesn't work, I usually suggest to go for <input type="text" pattern="\d+"/>.

您当然可以将模式更改为与数字相关的任何内容(例如(\d|[1-5]\d|60)可以将min设置为0,将max设置为60)

You can of course change your pattern to anything number-related (like (\d|[1-5]\d|60) to set min to 0 and max to 60)

这篇关于IE11输入类型=数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆