Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created December 2, 2015 03:58
Show Gist options
  • Save lamarmarshall/edecb5043d75420c9009 to your computer and use it in GitHub Desktop.
Save lamarmarshall/edecb5043d75420c9009 to your computer and use it in GitHub Desktop.
angular custom validation
<p>
<label for="full_name">Full Name</label>
<!-- each form must have name and html validation -->
<!-- must have ng-class variable object with classes like this -->
<input type="text" ng-model="formModel.fullname" name="full_name" required="required"
ng-pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$"
ng-class="{
green: theForm.full_name.$valid ,
red: !theForm.full_name.$valid && !theForm.$pristine
}"
>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment