From: harry Date: Sat, 22 Apr 2017 13:24:04 +0000 (+0530) Subject: Closes #9870 - Added a combo pattern `website` X-Git-Tag: v6.4.0-rc1~55^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=521d96400bce3e129d58f2df4fb1c648262f974b;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Closes #9870 - Added a combo pattern `website` Changes: - Added a pattern `website` which is basically a combo of both `domain` and `url` pattern - Also updated the docs! --- diff --git a/docs/pages/abide.md b/docs/pages/abide.md index ea17fc20d..629d330db 100644 --- a/docs/pages/abide.md +++ b/docs/pages/abide.md @@ -10,7 +10,7 @@ tags: ## Abide Demo -These input types create a text field: `text`, `date`, `datetime`, `datetime-local`, `email`, `month`, `number`, `password`, `search`, `tel`, `time`, `url`, and `week`. Note the use of the novalidate attribute to disable any browser validation that could conflict with Abide. +These input types create a text field: `text`, `date`, `datetime`, `datetime-local`, `email`, `month`, `number`, `password`, `search`, `tel`, `time`, `url`, `website` and `week`. Note the use of the novalidate attribute to disable any browser validation that could conflict with Abide. ```html_example
@@ -48,8 +48,8 @@ These input types create a text field: `text`, `date`, `datetime`, `datetime-loc
-
@@ -271,6 +271,8 @@ The following patterns and validators are already built in: `time`, `url` +Apart from these standard patterns, we have a `website` pattern too which is basically a combo of both `domain` and `url` pattern and we recommend you to use this `website` pattern for validating websites. + They are defined by regular expressions as you can see below. Note, that the patterns that relate to text such as `alpha` and `alpha_numeric` do not consider special characters from other languages. You need to add these special characters yourself to the regular expressions. For instance, for the German language you need to add: ```JS @@ -312,6 +314,13 @@ day_month_year : /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/, // #FFF or #FFFFFF color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ + +// Domain || URL +website: { + test: (text) => { + return Abide.defaults.patterns['domain'].test(text) || Abide.defaults.patterns['url'].test(text); + } +} ``` diff --git a/js/foundation.abide.js b/js/foundation.abide.js index cd15eb78b..c9fccf2c4 100644 --- a/js/foundation.abide.js +++ b/js/foundation.abide.js @@ -560,7 +560,14 @@ Abide.defaults = { day_month_year : /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/, // #FFF or #FFFFFF - color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ + color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, + + // Domain || URL + website: { + test: (text) => { + return Abide.defaults.patterns['domain'].test(text) || Abide.defaults.patterns['url'].test(text); + } + } }, /**