2

I'm writing a form in Angular and I have one criteria that requires that I need to check for that requires the input to ONLY contain letters and numbers AND the first character cannot be a number. Is there any way to easily check this in Angular. I'm aware that ngPattern exists, but I am not certain that it can be extended to this scenario. Anyone know the best way to format this in ngPattern or in the controller? Any leads would be much appreciated!

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Keren
  • 379
  • 6
  • 16

1 Answers1

0

Your pattern should be

ng-pattern = "/^[a-zA-Z]{1}[a-zA-Z0-9]*$"
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299