Ionic-3 ion-input maxlength attribute not working

前端 未结 3 1997
予麋鹿
予麋鹿 2021-02-19 03:55

I have tried to add ion-input for maxlength , max attribute but it\'s not working as per expectation.



        
3条回答
  •  孤城傲影
    2021-02-19 04:41

    According to this post: maxlength ignored for input type="number" in Chrome

    Maxlength doesn't work on input type="number"

    One alternative is suggested here: https://github.com/ionic-team/ionic/issues/7072 where dilhan119 suggests using type="tel"

    A robust solution is to use a form validator, which will prevent form submission (and can show the user an error): https://www.joshmorony.com/advanced-forms-validation-in-ionic-2/

提交回复
热议问题