How to put a mask in a ion-text input (FormControl)?


#1

How to put a mask in a ion-text input like a phone number maks?


#2

Can you adapt this to your needs?


#3

I’m not sure it will work in this case. I forgot to say I used FormBuilder and FormControls. It’s not a templated oriented form.


#4

What do you mean by mask? Something different from the form controls I’m guessing. The user can only type digits, for example? You could create a method to do that with ngModel and a regular expression I suppose. But the standard way to do it is to suggest to the browser that the browser should only display a keyboard with numbers on it. So you say “input type = telephone,” however the input field accepts that. But the bottom line is that you’re programming for the browser, across multiple platforms. So you’re often making suggestions, instead of forcing requirements. I try not to be too rigid, because there’s no way for me to know what might be tweaked in the next version of Safari, or of Android.


#5

By mask I mean an input mask like this.

I tried to create my own mask but but it deserver too much development effort to work perfectly and it’s not not too maintainable so I dropped it before finish.