1
Hi, I’m new to Angular and I’m having trouble with my mask! I’m wearing the masks of "Angular-input-Mask";
I have a form that has a field 'CPF', the mask is applied perfectly. Visually when I type a letter, this letter does not appear in the field, because the field 'CPF' accepts only numbers! However when I type a letter, this letter is stored with input, and my formGroup validation is activated automatically. I’d like to know how to prevent that!
In the photo below, I displayed the value of my form and fields and typed a letter. Note that the 'CPF' field is empty, but the input value is filled with the typed letter..
Form code...
put the code!
– Eduardo Vargas
Form code posted
– Guilherme Nunes
tentat put a type="number"
– Eduardo Vargas
and take off the ng model
– Eduardo Vargas
Then, type="number", cannot be, because if not the mask will not be applied, because it has ".. -", dots and dash.. And ngModel is the application of the mask tbm, if you take the mask to work...
– Guilherme Nunes
The problem is that you are mixing the reactive Forms(formControlName) with the Forms(ngmodel) template. recommend you make your own mask just look for the regex of Cpf.
– Eduardo Vargas
Got it! but how do I make this mask own? Using Jquery? Because I was using Jquery and was giving the same error, so I decided to change!! Does regex make mascara? until then I can use only for validation...
– Guilherme Nunes
take a look at that answer, you create your directive of Cpf https://stackoverflow.com/questions/37800841/input-mask-fields-in-angular2-forms
– Eduardo Vargas
vc tbm can look for a library that works with formcontrolname
– Eduardo Vargas
https://github.com/text-mask/text-mask/tree/master/angular2#readme
– Eduardo Vargas
Opah, I found the same that you posted, I will do the tests here and I warn you to mark the answer here! thank you very much..
– Guilherme Nunes
Opah, it worked 100%, can post the link as an answer I confirm here! thank you...
– Guilherme Nunes