我试图为 maxlength , max 属性添加 ion-input ,但它没有按预期工作 .
maxlength
max
ion-input
<ion-input type="number" placeholder="*" maxlength="1"></ion-input> <ion-input type="number" placeholder="*" max="1"></ion-input>
有谁知道相同的解决方案?
谢谢
根据这篇文章:maxlength ignored for input type="number" in Chrome
Maxlength对输入类型=“数字”不起作用
这里建议一种替代方案:https://github.com/ionic-team/ionic/issues/7072其中dilhan119建议使用type = "tel"
一个强大的解决方案是使用表单验证器,它将阻止表单提交(并可以向用户显示错误):https://www.joshmorony.com/advanced-forms-validation-in-ionic-2/
1 回答
根据这篇文章:maxlength ignored for input type="number" in Chrome
Maxlength对输入类型=“数字”不起作用
这里建议一种替代方案:https://github.com/ionic-team/ionic/issues/7072其中dilhan119建议使用type = "tel"
一个强大的解决方案是使用表单验证器,它将阻止表单提交(并可以向用户显示错误):https://www.joshmorony.com/advanced-forms-validation-in-ionic-2/