Im trying to implement a simple form validation.
If the input form is not touched and/or is invalid, the OK button should be disabled. Its not working, do I need a JS code as well?
Also the "required"in the input is not working too. I can still click ok without entering anything in the form and it will still be accepted as valid input. The character limit isnt working as well…all very odd.
Appreciate help on this, many thanks!
<ion-view ng-controller="MainCtrl">
<ion-nav-buttons side="left">
<button class="button button-icon ion-close-round" ng-click="close()"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-large button-assertive" ng-click="submitPost()"
ng-disabled="newPost.$invalid || newPost.$pristine">
<b>OK</b>
</button>
</ion-nav-buttons>
<ion-content class="padding has-header">
<form name="newPost">
<div>
<input type="text"
placeholder="input"
ng-model="post.title"
ng-maxlength="150"
required>
</div>
</form>
</ion-content>
</ion-view>