When using AngularJS for form validation, I want all required fields to be marked as erroneous when the user clicks submit.
To achieve this, I am utilizing input.ng-dirty.ng-invalid to style the controls with errors. My goal is to set ng-dirty on required controls (or all controls) when the form is submitted.
Although validation is functioning correctly, I realize that my approach may not be optimal. However, I have yet to find another method to replicate the desired effect without resorting to overly complex solutions.
In attempting to implement this idea, I used the following code:
<div ng-app>
<form novalidate>
<input name="formvalue" type="text" ng-model="formvalue" required />
<input type="submit" />
</form>
</div>