【问题标题】:maxlength not working with input type="number" ionicmaxlength 不适用于输入类型 =“数字” 离子
【发布时间】:2016-08-16 15:21:46
【问题描述】:

我尝试定义数字输入的最大长度。

 <label class="item item-input">
 <i class="icon ion-android-call placeholder-icon"></i>
 <input type="number"  placeholder="Phone number " maxlength="8">
 </label>

请问我该如何解决。

【问题讨论】:

  • 确实如此。您可以使用类型 tel 然后它工作。顺便说一句,如果您将应用程序用于 ios,那么您没有 number 类型。

标签: angularjs ionic-framework


【解决方案1】:
   <input type="tel " maxlength="6">

【讨论】:

  • 如果在桌面上使用网络浏览器,这不是一个可接受的答案,因为没有什么可以阻止您在字段中添加字母。到目前为止,Ionic 中似乎还没有针对这种情况的解决方案:-(
  • 好的,这个链接让事情变得更清楚,同时使用 maxlength 和输入标签的模式属性的解决方法:stackoverflow.com/questions/18510845/…
【解决方案2】:
 <input type="tel" pattern="[0-9]*" maxlength="6">

这也将验证数字模式:)

【讨论】:

    猜你喜欢
    • 2021-01-02
    • 2019-09-09
    • 2023-03-30
    • 1970-01-01
    • 2019-07-17
    • 1970-01-01
    • 2015-12-02
    • 2017-01-19
    • 1970-01-01
    相关资源
    最近更新 更多