I am creating a form with Ionic and want to validate the fields after the submitted form. The way I am doing it works, but when I open the page the fields are already marked as invalid and I want it to happen after the form is submitted if there is any field that has not been filled.
How do I do this?
I'm trying like this.
<form name="Empresa" novalidate ng-submit="addEmpresa(Empresa);">
<div class="list">
<label class="item item-input"
ng-class="{'has-errors':Empresa.nomeemp.$invalid, 'no-errors':Empresa.nomeemp.$valid}">
<input type="text"
placeholder="Nome"
name="nomeemp"
ng-model="Empresa.nome"
ng-required="true">
</label>
<div class="error-container"
ng-messages="Empresa.nomeemp.$error">
<div ng-messages-include="templates/form-errors.html"></div>
</div>
<button type="submit" class="button button-block button-energized">Cadastrar</button>
</form>