<input type="email" name="email" ng-model="contact.email" ng-required="true" ng-model-options="{ updateOn: 'blur' }"> <div class="alert alert-danger input-error" ng-show="ContactForm.email.$dirty && ContactForm.email.$invalid"> <button type="button" class="close" data-dismiss="alert">&times;</button> Введите корректный Email </div> 

There is such a code. Now it works like this: update the page - all the rules, click on the field, enter something - an alert-danger error pops up. How to make it pop up only after the end of the input? ng-model-options="{ updateOn: 'blur' }" did not help.

  • I think you need to look a little deeper, is it worth it to onchage? - Goshka Tarasov

1 answer 1

And try so

 <input type="email" name="email" ng-model="contact.email" ng-required="true" ng-model-options="{ updateOn: 'blur' }"> <div class="alert alert-danger input-error" ng-show="ContactForm.email.$touched && ContactForm.email.$invalid"> <button type="button" class="close" data-dismiss="alert">&times;</button> Введите корректный Email </div> 

The $touched property will be true when the input focus has left the field. Need Angular 1.3+