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.
Copy file name to clipboardExpand all lines: readme.md
+40-9Lines changed: 40 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ Huge rewrite to have a better code separation and also adding support to Service
22
22
23
23
<aname="index"></a>
24
24
## Index
25
+
*[Alternate Text on Validator](#alternate)
25
26
*[Available Validators](#validators)
26
27
*[Bootstrap Input Groups Wrapping - HOWTO](#input-groups-wrapping)
27
28
*[Changelog](#changelog)
@@ -317,13 +318,43 @@ Step #1-4 are for explanation only, at the end we show the full regex (make sure
317
318
318
319
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`
319
320
321
+
<aname="alternate"></a>
322
+
Alternate Text on Validators
323
+
--------------------
324
+
Validators can now use alternate text instead of the usual defined locale $translate text, for example it could be useful to see a different text on a `<select>` instead of the usual "Field is Required". This works on all type of validators and is defined by adding `:alt=` at the end of any validators, it could be used on 1 or more validators directly inside the `validation=""` attribute. See the examples below.
325
+
```html
326
+
<!-- You can use translate in your HTML -->
327
+
<!-- Example #1 with 1 alternate text on 1 of the 2 validators -->
// Example #2, alternate text on multiple validators
345
+
myValidationService.addValidator('input1', 'date_iso_between:2015-03-01,2015-03-30:alt=Booking date must be in April|required:alt=Booking Date is Required');
All validators are written as `snake_case` but it's up to the user's taste and could also be used as `camelCase`. So for example `alpha_dash_spaces` and `alphaDashSpaces` are both equivalent.
324
357
325
-
NEW Alternate Text: Validators can now use alternate text instead of the usual defined locale $translate text, for example it could be useful to see a different text on a `<select>` instead of the usual "Field is Required". This works on all type of validators and is defined by adding `:alt=` at the end of any validator and could be used on 1 validator or multiple validators. For example: `validation="required:alt=Your Alternate Required Text."` or `validation="date_iso_between:2015-03-01,2015-03-30:alt=Provide a Booking Date for April|required:Booking Date is Required"`. You could also use the `$translate` on the provided text, for example in the Directive you can use `validation="required: {{ 'YOUR_TEXT' | translate }}"` or in the Service you can use `....addValidator('input1', 'required:alt=' + $translate.instant('YOUR_TEXT'));`
326
-
327
358
##### NOTE: on an `input type="number"`, the `+` sign is an invalid character (browser restriction) even if you are using a `signed` validator. If you really wish to use the `+`, then change your input to a `type="text"`.
328
359
329
360
*`alpha` Only alpha characters (including latin) are present (a-z, A-Z)
@@ -373,16 +404,16 @@ NEW Alternate Text: Validators can now use alternate text instead of the usual d
373
404
*`ipv6` Check for valid IP (IPv6)
374
405
*`ipv6_hex` Check for valid IP (IPv6 Hexadecimal)
375
406
*`match:n` Match another input field(n), where (n) must be the exact ngModel attribute of input field to compare to.
376
-
*`match:n,t` Match another input field(n), same as (match:n) but also include (t) for alternate text (this only replace the input name) to be displayed in the error message.
407
+
*`match:n,t` Match another input field(n), same as (match:n) but also include (t) for alternate input name to be displayed in the error message (it still uses default translated text, if you really wish to replace the complete text error, then use [:alt](#alternate))
377
408
*`max_date_iso` alias of `date_iso_max`.
378
-
*`min_date_iso` alias of `date_iso_min`.
379
409
*`max_date_euro_long` alias of `date_euro_long_max`.
380
-
*`min_date_euro_long` alias of `date_euro_long_min`.
381
410
*`max_date_euro_short` alias of `date_euro_short_max`.
382
-
*`min_date_euro_short` alias of `date_euro_short_min`.
383
411
*`max_date_us_long` alias of `date_us_long_max`.
384
-
*`min_date_us_long` alias of `date_us_long_min`.
385
412
*`max_date_us_short` alias of `date_us_short_max`.
413
+
*`min_date_iso` alias of `date_iso_min`.
414
+
*`min_date_euro_long` alias of `date_euro_long_min`.
415
+
*`min_date_euro_short` alias of `date_euro_short_min`.
416
+
*`min_date_us_long` alias of `date_us_long_min`.
386
417
*`min_date_us_short` alias of `date_us_short_min`.
387
418
*`max_len:n` Checks field length, no longer than specified length where (n) is length parameter.
388
419
*`max_num:n` Checks numeric value to be lower or equal than the number (n).
@@ -392,8 +423,8 @@ NEW Alternate Text: Validators can now use alternate text instead of the usual d
392
423
*`numeric_signed` Only numeric value (float, integer) can also be signed (-/+).
393
424
*`regex` Ensure it follows a regular expression pattern... please see [Regex](#regex) section
394
425
*`required` Ensures the specified key value exists and is not empty
395
-
*`url` Check for valid URL or subdomain
396
426
*`time` Ensure time follows the format of (hh:mm) or (hh:mm:ss)
427
+
*`url` Check for valid URL or subdomain
397
428
398
429
<aname="dependencies"></a>
399
430
Dependencies
@@ -426,4 +457,4 @@ License
426
457
*[1.3.9](https://github.com/ghiscoding/angular-validation/commit/931d3b04a00f0583612aefe28ad0bfcac326a38c)`2015-03-21` Added validation summary through 2 new and equivalent properties `$scope.$validationSummary` and `$scope.formName.$validationSummary`. Also added `bower` and `gulp` support, the Gulp script gives minified files.
427
458
*[1.3.10](https://github.com/ghiscoding/angular-validation/commit/18765a8dd986856a9fa176fc4835d90d25f663b2)`2015-03-29` Added new function of `checkFormValidity()` before submitting the form. Now use only 1 minified script instead of multiples.
428
459
*[1.3.11](https://github.com/ghiscoding/angular-validation/commit/e807584f0bcdf0f28ef2ef905b6bc4e890926ac1)`2015-03-30` Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
429
-
*[1.3.12]()`2015-04-04` Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
460
+
*[1.3.12](https://github.com/ghiscoding/angular-validation/commit/0af82337a6961923e3b022a19660237d3e6f7184)`2015-04-04` Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
0 commit comments