Skip to content

Instantly share code, notes, and snippets.

@deepal
Created April 2, 2017 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deepal/c09b2033e8a539c06bbdc991352402ba to your computer and use it in GitHub Desktop.
Save deepal/c09b2033e8a539c06bbdc991352402ba to your computer and use it in GitHub Desktop.
<form name="myForm" novalidate class="form">
<div class="form-group" ng-class="{'has-error': myForm.name.$invalid}">
<label for="name">Name</label>
<input class="form-control" type="text" name="name" id="name" name-validator ng-model="name"/>
</div>
<div class="alert alert-danger" ng-show="myForm.$invalid">
<ul>
<li ng-show="myForm.name.$error.required">Name is required!</li>
<li ng-show="myForm.name.$error.min_length">Name should be at least two characters!</li>
<li ng-show="myForm.name.$error.invalid_chars">Name should only contain alphabetic characters!</li>
</ul>
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment