L
L
Ler Den2016-10-29 23:41:35
Angular
Ler Den, 2016-10-29 23:41:35

Angular ng-pattern. How to check the data?

Help solve the problem, please.
To begin with, I want to set a condition: all English letters.
From what I read in the documentation https://docs.angularjs.org/api/ng/directive/ngPattern
I don't quite understand why the pattern looks like this?
$scope.regex = '\\d+';
and not like in pure JS?
$scope.regex = '/\d+/';
My code

<form method="post" name="signupForm" ng-submit="register()" role="form">
  <input ng-pattern="username" type="text" name="displayName" ng-model="user.fullName" placeholder="Full Name" required>
</form>

$scope.username = "/^[a-zA-Z]*$/";
If I substitute "/^[a-zA-Z]*$/" directly into ng-pattern it works fine

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-10-29
@givemoneybiatch

The code is incomplete, so offhand:
$scope.username = /^[a-zA-Z]{5,25}$/;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question