Skip to content

Instantly share code, notes, and snippets.

@got5
Created December 13, 2014 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save got5/fabd51ee4221ebfc347a to your computer and use it in GitHub Desktop.
Save got5/fabd51ee4221ebfc347a to your computer and use it in GitHub Desktop.
Slide 144 Using form validation
<form name="myForm">
<h3>Training complaint form</h3>
<alert type="error" ng-if="myForm.txtContent.$error.maxlength">
Complaint message must be five characters long or less!
</alert>
Your name: <input type="text" name="inputName" ng-model="complaint.name" ng-required="true" />
Your mail: <input type="email" ng-required="true" name="inputMail" ng-model="complaint.mail" />
Your complaint: <input type="text" name="txtContent" ng-maxlength="5" ng-model="complaint.content" />
<button ng-disabled="!myForm.$valid" class="btn" ng-click="sendComplaint()">Send</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment