I have a form with a section of controls. I have a button which adds more sections on the form dynamically.
I have validations on each of those controls i.e. ng-required, and other validations.
I have a submit button and I have a validation error on click.
I have invalid values in the control and click submit, the validations are fired and all is good. After clicking the submit button if I try to add a new section, because the section has controls with empty values and since the form is submitted the validations fire and by default I see error messages, which is not a good user experience, hence can someone please help me to avoid this behaviour?
Please find below the code I have:
<div class="row bottom-spaced-large">
<div class="row">
<div class="col-md-3">
Number of ear tags
</div>
<div class="col-md-9">
<input name="txtNumber" tabindex="102" ng-pattern="/^[0-9]*$/" ng-maxlength="50" ng-model="someValue" class="form-control color-black" tabindex="3" />
<div class="row" style="padding-left: 30px" ng-if="someForm.$submitted && !someForm.txtNumber.$valid">
<span style="color: red">Number must be a positive number.</span>
</div>
</div>
</div>
</div>
<div class="row bottom-spaced-large">
<button type="button" class="btn btn-primary btn-add" tabindex="101" ng-click="addMore();">Add more<span aria-hidden="true" class="fa fa-plus"></span></button>
</div>
<button type="submit" class="btn btn-default btn-xs fixed-width" ng-click="doSomething()" tabindex="104">Next</button>