You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
Angular-Validation requires the element which will use validation to have an html `name=""` attribute, so that in the background it can use this name to create and show an error into a `<span>` which will directly follow your form input. For example: `<input name="input1" ng-model="input1" validation="required" />`.
70
88
71
89
*The necessity of `name=""` attribute is new since version 1.3.4+, prior to this change we were asking the user to create his own `<span>` for error displaying. In other words, the `<span>` is now optional, but the `name=""` attribute becomes mandatory and will throw an error if omitted*
72
90
73
-
<aname="examples-directives"></a>
91
+
<aname="examples-directive"></a>
74
92
## Some Working Examples (Directive)
75
93
Let's start with a simple example and then let's get down to real business.
76
94
@@ -175,6 +193,9 @@ The Angular-Validation concept was first introduced with the use `ngDisabled` on
175
193
```
176
194
```javascript
177
195
// Option #2 will need to call the `checkFormValidity()` function checking the form before doing a real submit
196
+
// $validationSummary can be found in 2 variables (depending if your form as a name or not)
197
+
// you can use `checkFormValidity($scope.form1)` or this `checkFormValidity($scope)`
198
+
// If your form does not have a name attribute, your only choice is `checkFormValidity($scope)`
@@ -211,6 +232,7 @@ Display a validation summary of all the current form errors. Validation summary
211
232
</form>
212
233
```
213
234
235
+
<aname="input-groups-wrapping"></a>
214
236
Bootstrap Input Groups Wrapping - HOWTO
215
237
--------------------
216
238
Well let's face it, having the `<span>` for error display right after the element to be validated is not always ideal and I encounter the problem myself when using Bootstrap on inputs with `input-group`, it had so much wrapping around the input that the next available element might not be the one we want. In these special occasions, we will add a `<span>` or a `<div>` for displaying the possible error and give the this element an `id="someId"` or a `class="className"` and then reference it inside our input. We could actually move the error element anywhere we want with this method, just don't forget to name it with an `id` or a `className` and call the `validation-error-to` attribute. This attribute could be called in 3 different ways: with `'.'` (element error className) or with/without `'#'` (element error id) We could even do a validation summary with this...just saying hehe.
@@ -250,7 +272,7 @@ From the example displayed, I introduce the custom regular expression, there is
250
272
251
273
Regex validation is divided in 4 specific parts (Step #1-4).
252
274
253
-
Let's use the previous [Examples #5](#examples-directives) and extract the information out of it to see how it works.
275
+
Let's use the previous [Examples #5](#examples-directive) and extract the information out of it to see how it works.
254
276
Step #1-4 are for explanation only, at the end we show the full regex (make sure there is no spaces).
255
277
256
278
1. Start & end the filter with the following `regex: :regex` which tells the directive where to extract it.
@@ -263,7 +285,7 @@ Step #1-4 are for explanation only, at the end we show the full regex (make sure
263
285
264
286
Final code (without spaces): `regex:YYWW:=^(0[9]|1[0-9]|2[0-9]|3[0-9])(5[0-2]|[0-4][0-9])$:regex`
265
287
266
-
288
+
<aname="locales"></a>
267
289
Locales (languages)
268
290
--------------------
269
291
Locales are simple sets of language defined in external JSON files, we can easily add any new language as extra files without affecting the behaviour of the angular directive. You could even change displayed language on the fly (note that the error message will be reflected only after field value is re-evaluated). Make sure to include the `angular-translate` library and configure it, see section [Include it in your Project](#project)
@@ -281,9 +303,9 @@ $scope.switchLanguage = function (key) {
281
303
});
282
304
};
283
305
```
284
-
285
306
*P.S. If you define a new Language set, please make a pull request and I would be happy to add them in current project... It would be nice to have Spanish, German or even Chinese :) Thank you.*
286
307
308
+
<aname="validators"></a>
287
309
Available Validators
288
310
--------------------
289
311
All validators are written as `snake_case` but it's up to the user's taste and could also be written as `camelCase`. So for example `alpha_dash_spaces` and `alphaDashSpaces` are both equivalent.
@@ -374,6 +396,7 @@ License
374
396
* Add more validators...
375
397
* Add more locale languages... I need your help on that one!!!
376
398
399
+
<aname="changelog"></a>
377
400
## CHANGELOG
378
401
*[1.3.0](https://github.com/ghiscoding/angular-validation/commit/d106996926bef86a0457c90fbb65fe6233f3928d)`2014-12-01` Added support to AngularJS 1.3
0 commit comments