74 |
75 | 76 | 79 |

Requirements

80 |
81 |

AngularJS 1.2.x (for angular-validation 1.2.x)

82 |

AngularJS 1.3.x (for angular-validation 1.3.x)

83 |

Installation

84 |
85 |
86 |

Install with npm

87 |
npm install angular-validation 
88 |

Or with Bower

89 |
bower install angular-validation 
90 |
91 |
92 |

Files to download

93 |
94 |

Add the files to your html

95 |
<script src="dist/angular-validation.js"></script>
 96 | <script src="dist/angular-validation-rule.js"></script>
97 |

If you are using Bower:

98 |
<script src="lib/angular-validation/dist/angular-validation.js"></script>
 99 | <script src="lib/angular-validation/dist/angular-validation-rule.js"></script>
100 |
angular.module('yourApp', ['validation']);
101 |

Including your validation rule

102 |
103 |
angular.module('yourApp', ['validation', 'validation.rule']);
104 |
105 |
106 |

Writing your first code

107 |
108 |
<form name="Form">
109 |         <div class="row">
110 |             <div>
111 |                 <label>Required</label>
112 |                 <input type="text" name="required" ng-model="form.required" validator="required"></div>
113 |                 <div>
114 |                     <label>Url</label>
115 |                     <input type="text" name="url" ng-model="form.url" validator="required, url">
116 |                 </div>
117 |                 <button validation-submit="Form" ng-click="next()">Submit</button>
118 |                 <button validation-reset="Form">Reset</button>
119 |         </div>
120 | </form>
121 |
122 |
123 | 124 | 125 | 126 |
127 | 128 | 131 |

You can style different states of your form elements using the following selectors

132 | Invalid Selectors 133 |
134 |
.ng-invalid.ng-dirty { /* Your style here */ }
135 |
136 | Valid Selectors 137 |
138 |
.ng-valid.ng-dirty { /* Your style here */ }
139 |
140 |
141 |

142 | You can also include your vendor libraries classes in you are using CSS preprocessors such as 143 | LESS or 144 | SASS. 145 |

146 | Using Bootstrap classes 147 |
148 |
.ng-valid.ng-dirty { .has-error .form-control; }
149 |
150 | 151 |
152 | 153 |

For more on AngularJS validation classes check at their 154 | documentation. 155 |

156 | 157 | 158 |
159 | 160 | 163 | 164 | 205 | 206 | 228 | 229 | 230 | 260 | 261 | 262 | 300 | 301 | 302 | 356 | 357 | 358 | 381 | 382 | 383 | 403 | 404 | 405 | 439 | 440 | 441 | 442 |