0
Hello, I have a problem with regex and angular.
I have an input that uses ngModel, and I need to use a regex on it to prevent the user from initially entering a number, that is, the first input must not be a number.
The problem is, I can’t find a regex that does that and I can’t apply any regex with ngModel.
Could someone please help me. My input is like this at the moment:
 <input 
     placeholder="Input name" 
     class="inputs" 
     value="{{input.inputField}}"
     pattern="^[a-z]"
     [(ngModel)]="input[i].inputField" />
Thank you in advance...
You can create a function and call it in the onKeyDown attribute of your input, and in it do this first character validation as letter and the rest as numbers.
– Maycon F. Castro
It’s not just changing the
patternforng-pattern? https://docs.angularjs.org/api/ng/directive/ngPattern#Usage– hkotsubo
uses directive, easier
– Joannis
http://kazale.com/angular-2-mascara-entrada-dados-input-mask-diretivas/
– Joannis