Where is maxLength on ion-input?

Thanks @ishaquemujtaba, input type support text also, my need is “input type should be number with maxlength 10”

just do like this
<ion-input [(ngModel)]=“number” type=“number” (ionInput)=“getMax()”>

@ishaquemujtaba not working

I think the condition should be like this if(this.number.length >= 10) then it will work.

we can use input type as a tel. Because “textinput” way is working for input type as a text and telephone number.

<ion-input type="tel" maxlength="3"></ion-input>

this works for me

this is an alternative i think…

This is for a number input

articuloLength(event){
if(event.target.value.length > 5){
let val = event.target.value.toString().slice(0,-1);
event.target.value = parseInt(val);
}
}

you can set type as string and use pattern to show keypad as number:


<ion-input type="text" pattern="[0-9]*" maxlength="3"></ion-input>
1 Like