加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

HTML maxlength属性不适用于chrome和safari?

发布时间:2020-12-14 21:21:41 所属栏目:资源 来源:网络整理
导读:input type="number" maxlength="5" class="search-form-input" name="techforge_apartmentbundle_searchformtype[radius]" id="techforge_apartmentbundle_searchformtype_radius" 这是我的HTML,用firebug(在chrome上)。 我可以在表单字段中编写尽可能多的
<input type="number" maxlength="5" class="search-form-input" name="techforge_apartmentbundle_searchformtype[radius]" id="techforge_apartmentbundle_searchformtype_radius">

这是我的HTML,用firebug(在chrome上)。

我可以在表单字段中编写尽可能多的字符 – 在Chrome和Safari中。

在Firefox或IE10上,限制很好。

我没有在网上找到这个问题。

注意:type =“number” – 不是文本。

有人以前见过这个问题吗?

解决方法

对于type =“number”的输入使用max属性。它将指定您可以插入的最高编号
<input type="number" max="999" />

如果同时添加最大值和最小值,则可以指定允许值的范围:

<input type="number" min="1" max="999" />

见example

编辑

如果为了用户体验,您希望用户不能输入超过一定数量的数字,请使用Javascript / jQuery,如此example所示

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读