如何设置输入类型的最大长度=数字? [英] How to set maximum length in input type=number?

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

问题描述

我有一个文本字段。

 < input type =numbermin =0max =999 > 

但是我可以在文本框内键入尽可能多的数字。



当我设置最大值= 999时,我不希望发生这种情况。
任何人都知道这个解决方案?
我试过 ng-maxlength maxlength ,但不起作用。

解决方案

max attribue指定我们可以指定的最大可能值。
$ b

了解更多详情看到这个链接



我认为以下内容对您有所帮助, $ b

  // maxlength =10
< input type =numberonKeyPress =if(this.value.length == 10)return false; />


I have a text field.

<input type="number" min="0" max="999">

But i am able to type as many numbers inside the text box.

As I set max=999, I don't want that to happen. Anyone knows the solution for this? I have tried ng-maxlength and maxlength but doesn't work.

解决方案

max attribue specifies the maximum possible value that we can specify.

for more details see this link

I think the following will be helpful to you,

//maxlength="10"
<input type="number" onKeyPress="if(this.value.length==10) return false;" />

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

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