]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Closes #9870 - Added a combo pattern `website`
authorharry <harmanmanchanda182@gmail.com>
Sat, 22 Apr 2017 13:24:04 +0000 (18:54 +0530)
committerharry <harmanmanchanda182@gmail.com>
Sat, 22 Apr 2017 13:24:04 +0000 (18:54 +0530)
Changes:
- Added a pattern `website` which is basically a combo of both `domain` and `url` pattern
- Also updated the docs!

docs/pages/abide.md
js/foundation.abide.js

index ea17fc20d62cbbd7f932dfea90ca41ca95e5be6b..629d330db26d456d34ec6df36843a13cf0423ee6 100644 (file)
@@ -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
 <form data-abide novalidate>
@@ -48,8 +48,8 @@ These input types create a text field: `text`, `date`, `datetime`, `datetime-loc
   </div>
   <div class="row">
     <div class="medium-6 columns">
-      <label>URL Pattern, not required, but throws error if it doesn't match the Regular Expression for a valid URL.
-        <input type="text" placeholder="http://foundation.zurb.com" pattern="url">
+      <label>Website Pattern, not required, but throws error if it doesn't match the Regular Expression for a valid URL or a Domain.
+        <input type="text" placeholder="http://zurb.com or zurb.com" pattern="website">
       </label>
     </div>
     <div class="medium-6 columns">
@@ -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);
+  }
+}
 ```
 
 
index cd15eb78b067aa2601b4abfd59c9de2f2625a36e..c9fccf2c4c9dab657f40a5d3139efe511f0018d7 100644 (file)
@@ -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);
+      }
+    }
   },
 
   /**