5

I try to define maxlength of a number input.

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

How can i reesolve it please.

Sihem Hcine
  • 1,089
  • 5
  • 24
  • 40

2 Answers2

8
   <input type="tel " maxlength="6">
Mohsin Muzawar
  • 1,202
  • 9
  • 9
  • 1
    This is not an acceptable answer if using a web browser on the desktop as there is nothing to stop you adding letters into the field. There seems currently to be no solution for this scenario in Ionic so far :-( – Kieran Ryan Jun 26 '17 at 13:20
  • Okay this link makes things clearer along with a workaround using maxlength and the pattern attribute of the input tag: https://stackoverflow.com/questions/18510845/maxlength-ignored-for-input-type-number-in-chrome/18510925#18510925 – Kieran Ryan Jun 26 '17 at 14:14
4
 <input type="tel" pattern="[0-9]*" maxlength="6">

This will validate the numbers pattern too :)