ngFormValidator is an easy to use, highly customizable front-end validation framework.
It can be used to show realtime validation status in form controls. It uses bootstrap styles to provide visual indication of validity of each control additon to a customizable error message. Further it supports overriding the styles with custom implementations.
http://adipa-g.github.io/ngFormValidator.html
<script src="dist/ngFormValidator.js"></script>//add module dependency
angular.module('myApp', ['ngFormValidator']);<!--you could also use ng-form-->
<form name="introform" ng-controller="intro">
<div class="form-group" validator="required">
<label for="requiredField">Required Field</label>
<input type="text" class="form-control" id="requiredField" name="requiredField"
placeholder="Required Field" ng-model="requiredField">
</div>
<button type="submit" class="btn btn-default" ng-disabled="!introform.$valid">Submit</button>
</form>- Required
- String (min and max length)
Default implementation use bootstrap classes. So you only need to include bootstrap.css in your page.
It uses 'has-success' to indicate successful validation, 'has-error' to a validation error and 'bg-error' for the error message.
To integrate this package with Bootstrap you should do the following.
.val-success{
//your style
}
.val-error{
//your style
}
.val-error-message{
//your style
}You could override style per form control
<!--you could also use ng-form-->
<form name="introform" ng-controller="intro">
<div class="form-group" validator="required" v-style-success="val-success" v-style-error="val-error" v-style-error-message="val-error-message">
<label for="requiredField">Required Field</label>
<input type="text" class="form-control" id="requiredField" name="requiredField"
placeholder="Required Field" ng-model="requiredField">
</div>
<button type="submit" class="btn btn-default" ng-disabled="!introform.$valid">Submit</button>
</form>Further you can define common styles for all form controls, in your controller than repeat specifying styles in each control.
$scope.validator = {
successStyle: 'val-success',
errorStyle: 'val-error',
errorMessageStyle: 'val-error-message'
};Also if you have multiple forms and if you need to use different styles in different forms, still it's possible
//make sure to use correct form name here ($scope.validator.{{form name}})
$scope.validator.introform = {
successStyle: 'val-success',
errorStyle: 'val-error',
errorMessageStyle: 'val-error-message'
};See release
GNU GPL V3