This is a typical example of using ng messages in AngularJS (1.x):
<form name="demoForm">
<input name="amount" type="number" ng-model="amount" max="100" required>
<div ng-messages="demoForm.amount.$error">
<div ng-message="required">This field is required</div>
</div>
<button type="submit">test submit</button>
</form>
see http://jsfiddle.net/11en8swy/3/
Now I want to change this example so that the error "This field was required" is displayed only when the field ( $touched) is touched or the user clicks the submit button.
I cannot use the class ng-submittedon the form, because a validation error prevents the form from being submitted.
How should I do it?
thank
source
share