Answer the question
In order to leave comments, you need to log in
How to check for some invalid characters?
There is a form consisting of one field. There is a set of characters that are allowed in this field. As a result, validation works without problems.
<form name='f1'>
<input type="text" name="i1" ng-model="i1" required ng-pattern="/^[A-Za-z0-9!#$%&'()*+,-./:;<=>[email protected]^_`{|}~]+$/">
<button ng-click="send(f1)">send</button>
<errors>
<error ng-if="f1.i1.$error.required && f1.i1.$touched">
обязательное поле
</error>
<error ng-if="f1.i1.$error.pattern && f1.i1.$touched">
недопустимый символ
</error>
</errors>
</form>
import HomeCtrl from './home.controller';
homeModule.controller('HomeCtrl', HomeCtrl);
function HomeCtrl($scope) {
$scope.i1 = null;
function send(f1) {
console.log(f1)
}
}
ng-pattern="/^[A-Za-z0-9!"#$%&'()*+,-./:;<=>[email protected][\]^_`{|}~]+$/"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question