浏览代码

Merge pull request #1154 from vsn4ik/3.x-match-to-test

Use inline regexp when possible
Robin Herbots 10 年之前
父节点
当前提交
cf2e7fc857
共有 2 个文件被更改,包括 251 次插入243 次删除
  1. 246 238
      README.md
  2. 5 5
      js/inputmask.js

+ 246 - 238
README.md

@@ -18,7 +18,7 @@ Highlights:
 - non-greedy masks
 - many features can be enabled/disabled/configured by options
 - supports readonly/disabled/dir="rtl" attributes
-- support data-inputmask attribute(s)  
+- support data-inputmask attribute(s)
 - alternator-mask
 - regex-mask
 - dynamic-mask
@@ -38,43 +38,43 @@ Include the js-files which you can find in the `dist` folder.
 via Inputmask class
 
 ```html
-<script src="jquery.js" type="text/javascript"></script>
-<script src="inputmask.js" type="text/javascript"></script>
-<script src="inputmask.???.Extensions.js" type="text/javascript"></script>
+<script src="jquery.js"></script>
+<script src="inputmask.js"></script>
+<script src="inputmask.???.Extensions.js"></script>
 ```
 
 ```javascript
-   var selector = document.getElementById("selector");
+var selector = document.getElementById("selector");
 
-   var im = new Inputmask("99-9999999");
-   im.mask(selector);
+var im = new Inputmask("99-9999999");
+im.mask(selector);
 
-   Inputmask({"mask": "(999) 999-9999", .... other options .....}).mask(selector);
-   Inputmask("9-a{1,3}9{1,3}").mask(selector);
-   Inputmask("9", { repeat: 10 }).mask(selector);
+Inputmask({"mask": "(999) 999-9999", .... other options .....}).mask(selector);
+Inputmask("9-a{1,3}9{1,3}").mask(selector);
+Inputmask("9", { repeat: 10 }).mask(selector);
 ```
 
 via jquery plugin
 
 ```html
-<script src="jquery.js" type="text/javascript"></script>
-<script src="inputmask.js" type="text/javascript"></script>
-<script src="inputmask.???.Extensions.js" type="text/javascript"></script>
-<script src="jquery.inputmask.js" type="text/javascript"></script>
+<script src="jquery.js"></script>
+<script src="inputmask.js"></script>
+<script src="inputmask.???.Extensions.js"></script>
+<script src="jquery.inputmask.js"></script>
 ```
 
 or with the bundled version
 
 ```html
-<script src="jquery.js" type="text/javascript"></script>
-<script src="jquery.inputmask.bundle.js" type="text/javascript"></script>
+<script src="jquery.js"></script>
+<script src="jquery.inputmask.bundle.js"></script>
 ```
 
 ```javascript
 $(document).ready(function(){
-   $(selector).inputmask("99-9999999");  //static mask
-   $(selector).inputmask({"mask": "(999) 999-9999"}); //specifying options
-   $(selector).inputmask("9-a{1,3}9{1,3}"); //mask with dynamic syntax
+  $(selector).inputmask("99-9999999");  //static mask
+  $(selector).inputmask({"mask": "(999) 999-9999"}); //specifying options
+  $(selector).inputmask("9-a{1,3}9{1,3}"); //mask with dynamic syntax
 });
 ```
 
@@ -88,9 +88,9 @@ via data-inputmask attribute
 
 ```javascript
 $(document).ready(function(){
-    $(":input").inputmask();
-    or
-    Inputmask().mask(document.querySelectorAll("input"));
+  $(":input").inputmask();
+  or
+  Inputmask().mask(document.querySelectorAll("input"));
 });
 ```
 
@@ -103,8 +103,8 @@ Any option can also be passed through the use of a data attribute. Use data-inpu
 
 ```javascript
 $(document).ready(function(){
-   $("#example1").inputmask("99-9999999");
-   $("#example2").inputmask("Regex");
+  $("#example1").inputmask("99-9999999");
+  $("#example2").inputmask("Regex");
 });
 ```
 
@@ -112,7 +112,7 @@ If you like to automatically bind the inputmask to the inputs marked with the da
 
 ```html
 ...
-<script src="inputmask.binding.js" type="text/javascript"></script>
+<script src="inputmask.binding.js"></script>
 ...
 ```
 
@@ -158,8 +158,8 @@ These are the very basic of masking.  The mask is defined and will not change du
 
 ```javascript
 $(document).ready(function(){
-   $(selector).inputmask("aa-9999");  //static mask
-   $(selector).inputmask({mask: "aa-9999"});  //static mask
+  $(selector).inputmask("aa-9999");  //static mask
+  $(selector).inputmask({mask: "aa-9999"});  //static mask
 });
 ```
 
@@ -172,16 +172,20 @@ Example:
 $('#test').inputmask('(99) 9999[9]-9999');
 ```
 
-This mask wil allow input like `(99) 99999-9999` or `(99) 9999-9999`.<br>Input => 12123451234      mask => (12) 12345-1234    (trigger complete)<br>Input => 121234-1234      mask => (12) 1234-1234     (trigger complete)<br>Input => 1212341234       mask => (12) 12341-234_    (trigger incomplete)  
+This mask wil allow input like `(99) 99999-9999` or `(99) 9999-9999`.
+
+Input => 12123451234      mask => (12) 12345-1234    (trigger complete)<br>
+Input => 121234-1234      mask => (12) 1234-1234     (trigger complete)<br>
+Input => 1212341234       mask => (12) 12341-234_    (trigger incomplete)
 
 #### skipOptionalPartCharacter
-As an extra there is another configurable character which is used to skip an optional part in the mask.  
+As an extra there is another configurable character which is used to skip an optional part in the mask.
 
 ```javascript
-skipOptionalPartCharacter: " ",
+skipOptionalPartCharacter: " "
 ```
 
-Input => 121234 1234      mask => (12) 1234-1234     (trigger complete)  
+Input => 121234 1234      mask => (12) 1234-1234     (trigger complete)
 
 When `clearMaskOnLostFocus: true` is set in the options (default), the mask will clear out the optional part when it is not filled in and this only in case the optional part is at the end of the mask.
 
@@ -211,66 +215,67 @@ Also {+} and {*} is allowed. + start from 1 and * start from 0.
 
 ```javascript
 $(document).ready(function(){
-   $(selector).inputmask("aa-9{4}");  //static mask with dynamic syntax
-   $(selector).inputmask("aa-9{1,4}");  //dynamic mask ~ the 9 def can be occur 1 to 4 times
-
-   //email mask
-   $(selector).inputmask({
-            mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
-            greedy: false,
-            onBeforePaste: function (pastedValue, opts) {
-                pastedValue = pastedValue.toLowerCase();
-                return pastedValue.replace("mailto:", "");
-            },
-            definitions: {
-                '*': {
-                    validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
-                    cardinality: 1,
-                    casing: "lower"
-                }
-            }
-    });
+  $(selector).inputmask("aa-9{4}");  //static mask with dynamic syntax
+  $(selector).inputmask("aa-9{1,4}");  //dynamic mask ~ the 9 def can be occur 1 to 4 times
+
+  //email mask
+  $(selector).inputmask({
+    mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
+    greedy: false,
+    onBeforePaste: function (pastedValue, opts) {
+      pastedValue = pastedValue.toLowerCase();
+      return pastedValue.replace("mailto:", "");
+    },
+    definitions: {
+      '*': {
+        validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
+        cardinality: 1,
+        casing: "lower"
+      }
+    }
+  });
+});
 ```
 
 ### Alternator masks
 The alternator syntax is like an **OR** statement.  The mask can be one of the 2 choices specified in the alternator.
 
-To define an alternator use the |.<br>ex: "a|9" => a or 9<br>    "(aaa)|(999)" => aaa or 999  
+To define an alternator use the |.<br>ex: "a|9" => a or 9<br>    "(aaa)|(999)" => aaa or 999
 
-Also make sure to read about the keepStatic option.  
+Also make sure to read about the keepStatic option.
 
 ```javascript
 $("selector").inputmask("(99.9)|(X)", {
-                definitions: {
-                    "X": {
-                        validator: "[xX]",
-                        cardinality: 1,
-                        casing: "upper"
-                    }
-                }
-            });
+  definitions: {
+    "X": {
+      validator: "[xX]",
+      cardinality: 1,
+      casing: "upper"
+    }
+  }
+});
 ```
 
 or
 
 ```javascript
 $("selector").inputmask({
-                mask: ["99.9", "X"],
-                definitions: {
-                    "X": {
-                        validator: "[xX]",
-                        cardinality: 1,
-                        casing: "upper"
-                    }
-                }
-            });
+  mask: ["99.9", "X"],
+  definitions: {
+    "X": {
+      validator: "[xX]",
+      cardinality: 1,
+      casing: "upper"
+    }
+  }
+});
 ```
 
 ### Preprocessing masks
 You can define the mask as a function which can allow to preprocess the resulting mask.  Example sorting for multiple masks or retrieving mask definitions dynamically through ajax. The preprocessing fn should return a valid mask definition.
 
 ```javascript
-  $(selector).inputmask({ mask: function () { /* do stuff */ return ["[1-]AAA-999", "[1-]999-AAA"]; }});
+$(selector).inputmask({ mask: function () { /* do stuff */ return ["[1-]AAA-999", "[1-]999-AAA"]; }});
 ```
 
 ### JIT Masking
@@ -280,7 +285,7 @@ Default: false
 Value can be true or a threshold number or false.
 
 ```javascript
-   Inputmask("date", { jitMasking: true }).mask(selector);
+Inputmask("date", { jitMasking: true }).mask(selector);
 ```
 
 ## Define custom definitions
@@ -289,17 +294,17 @@ You can define your own definitions to use in your mask.<br>Start by choosing a
 ### validator(chrs, maskset, pos, strict, opts)
 Next define your validator.  The validator can be a regular expression or a function.
 
-The return value of a validator can be true,  false or a command object.  
+The return value of a validator can be true,  false or a command object.
 
 #### Options of the command object
 - pos : position to insert
 - c : character to insert
 - caret : position of the caret
-- remove : position(s) to remove  
+- remove : position(s) to remove
   - pos or [pos1, pos2]
 
-- insert : position(s) to add :  
-  - { pos : position to insert, c : character to insert }  
+- insert : position(s) to add :
+  - { pos : position to insert, c : character to insert }
   - [{ pos : position to insert, c : character to insert }, { ...}, ... ]
 
 - refreshFromBuffer :
@@ -317,48 +322,48 @@ When you insert or delete characters, they are only shifted when the definition
 
 ```javascript
 Inputmask.extendDefinitions({
-    'f': {  //masksymbol
-        "validator": "[0-9\(\)\.\+/ ]",
-        "cardinality": 1,
-        'prevalidator': null
+  'f': {  //masksymbol
+    "validator": "[0-9\(\)\.\+/ ]",
+    "cardinality": 1,
+    'prevalidator': null
+  },
+  'g': {
+    "validator": function (chrs, buffer, pos, strict, opts) {
+      //do some logic and return true, false, or { "pos": new position, "c": character to place }
+    }
+    "cardinality": 1,
+    'prevalidator': null
+  },
+  'j': { //basic year
+    validator: "(19|20)\\d{2}",
+    cardinality: 4,
+    prevalidator: [
+      { validator: "[12]", cardinality: 1 },
+      { validator: "(19|20)", cardinality: 2 },
+      { validator: "(19|20)\\d", cardinality: 3 }
+    ]
+  },
+  'x': {
+    validator: "[0-2]",
+    cardinality: 1,
+    definitionSymbol: "i" //this allows shifting values from other definitions, with the same masksymbol or definitionSymbol
+  },
+  'y': {
+    validator: function (chrs, buffer, pos, strict, opts) {
+      var valExp2 = new RegExp("2[0-5]|[01][0-9]");
+      return valExp2.test(buffer[pos - 1] + chrs);
     },
-    'g': {
-        "validator": function (chrs, buffer, pos, strict, opts) {
-            //do some logic and return true, false, or { "pos": new position, "c": character to place }
-        }
-        "cardinality": 1,
-        'prevalidator': null
+    cardinality: 1,
+    definitionSymbol: "i"
+  },
+  'z': {
+    validator: function (chrs, buffer, pos, strict, opts) {
+      var valExp3 = new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]");
+      return valExp3.test(buffer[pos - 2] + buffer[pos - 1] + chrs);
     },
-    'j': { //basic year
-            validator: "(19|20)\\d{2}",
-            cardinality: 4,
-            prevalidator: [
-                        { validator: "[12]", cardinality: 1 },
-                        { validator: "(19|20)", cardinality: 2 },
-                        { validator: "(19|20)\\d", cardinality: 3 }
-            ]
-     },
-     'x': {
-        validator: "[0-2]",
-        cardinality: 1,
-        definitionSymbol: "i" //this allows shifting values from other definitions, with the same masksymbol or definitionSymbol
-     },
-     'y': {
-        validator: function (chrs, buffer, pos, strict, opts) {
-                        var valExp2 = new RegExp("2[0-5]|[01][0-9]");
-                        return valExp2.test(buffer[pos - 1] + chrs);
-                    },
-        cardinality: 1,
-        definitionSymbol: "i"
-     },
-     'z': {
-        validator: function (chrs, buffer, pos, strict, opts) {
-                       var valExp3 = new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]");
-                        return valExp3.test(buffer[pos - 2] + buffer[pos - 1] + chrs);
-        },
-        cardinality: 1,
-        definitionSymbol: "i"
-      }
+    cardinality: 1,
+    definitionSymbol: "i"
+  }
 });
 ```
 
@@ -370,7 +375,7 @@ Defaults can be set as below.
 
 ```javascript
 Inputmask.extendDefaults({
-    'autoUnmask': true
+  'autoUnmask': true
 });
 Inputmask.extendDefinitions({
   'A': {
@@ -397,40 +402,41 @@ But if the property is defined within an alias you need to set it for the alias
 
 ```javascript
 Inputmask.extendAliases({
-  'numeric' : {
+  'numeric': {
     allowPlus: false,
     allowMinus: false
-}});
+  }
+});
 ```
 
 However, the preferred way to alter properties for an alias is by creating a new alias which inherits from the default alias definition.
 
 ```javascript
 Inputmask.extendAliases({
-    'myNum': {
-            alias: "numeric",
-            placeholder: '',
-            allowPlus: false,
-            allowMinus: false
-        }
+  'myNum': {
+    alias: "numeric",
+    placeholder: '',
+    allowPlus: false,
+    allowMinus: false
+  }
 });
 ```
 
-Once defined, you can call the alias by:  
+Once defined, you can call the alias by:
 
 ```javascript
- $(selector).inputmask("myNum");
+$(selector).inputmask("myNum");
 ```
 
 All callbacks are implemented as options.  This means that you can set general implementations for the callbacks by setting a default.
 
 ```javascript
 Inputmask.extendDefaults({
-    onKeyValidation: function(key, result){
-                        if (!result){
-                            alert('Your input is not valid')
-                          }
-                    }
+  onKeyValidation: function(key, result){
+    if (!result){
+      alert('Your input is not valid')
+    }
+  }
 });
 ```
 
@@ -439,19 +445,19 @@ Inputmask.extendDefaults({
 Create a mask for the input.
 
 ```javascript
-   $(selector).inputmask({ mask: "99-999-99"});
+$(selector).inputmask({ mask: "99-999-99"});
 ```
 
-   or
+or
 
 ```javascript
-   Inputmask({ mask: "99-999-99"}).mask(document.querySelectorAll(selector));
+Inputmask({ mask: "99-999-99"}).mask(document.querySelectorAll(selector));
 ```
 
-   or
+or
 
 ```javascript
-   Inputmask("99-999-99").mask(document.querySelectorAll(selector));
+Inputmask("99-999-99").mask(document.querySelectorAll(selector));
 ```
 
 or
@@ -471,14 +477,14 @@ Inputmask("99-999-99").mask(selector);
 Get the `unmaskedvalue`
 
 ```javascript
-   $(selector).inputmask('unmaskedvalue');
+$(selector).inputmask('unmaskedvalue');
 ```
 
 or
 
 ```javascript
 var input = document.getElementById(selector);
-if(input.inputmask)
+if (input.inputmask)
   input.inputmask.unmaskedvalue()
 ```
 
@@ -493,14 +499,14 @@ var unformattedDate = Inputmask.unmask("23/03/1973", { alias: "dd/mm/yyyy"}); //
 Remove the `inputmask`.
 
 ```javascript
-    $(selector).inputmask('remove');
+$(selector).inputmask('remove');
 ```
 
 or
 
 ```javascript
 var input = document.getElementById(selector);
-if(input.inputmask)
+if (input.inputmask)
   input.inputmask.remove()
 ```
 
@@ -515,8 +521,8 @@ return the default (empty) mask value
 
 ```javascript
 $(document).ready(function(){
-   $("#test").inputmask("999-AAA");
-   var initialValue = $("#test").inputmask("getemptymask");  // initialValue  => "___-___"
+  $("#test").inputmask("999-AAA");
+  var initialValue = $("#test").inputmask("getemptymask");  // initialValue  => "___-___"
 });
 ```
 
@@ -525,13 +531,14 @@ Check whether the returned value is masked or not; currently only works reliably
 
 ```javascript
 $(document).ready(function(){
-    function validateMaskedValue(val){}
-    function validateValue(val){}
-
-    var val = $("#test").val();
-    if($("#test").inputmask("hasMaskedValue"))
-      validateMaskedValue(val);
-   else validateValue(val);
+  function validateMaskedValue(val){}
+  function validateValue(val){}
+
+  var val = $("#test").val();
+  if ($("#test").inputmask("hasMaskedValue"))
+    validateMaskedValue(val);
+  else
+    validateValue(val);
 });
 ```
 
@@ -540,14 +547,14 @@ Verify whether the current value is complete or not.
 
 ```javascript
 $(document).ready(function(){
-    if($(selector).inputmask("isComplete")){
-        //do something
-    }
+  if ($(selector).inputmask("isComplete")){
+    //do something
+  }
 });
 ```
 
 ### getmetadata
-The metadata of the actual mask provided in the mask definitions can be obtained by calling getmetadata.  If only a mask is provided the mask definition will be returned by the getmetadata.  
+The metadata of the actual mask provided in the mask definitions can be obtained by calling getmetadata.  If only a mask is provided the mask definition will be returned by the getmetadata.
 
 ```javascript
 $(selector).inputmask("getmetadata");
@@ -562,7 +569,7 @@ Get or set an option on an existing inputmask.
 ```javascript
 $("#CellPhone").inputmask("option", {
   onBeforePaste: function (pastedValue, opts) {
-      return phoneNumOnPaste(pastedValue, opts);
+    return phoneNumOnPaste(pastedValue, opts);
   }
 })
 $("#CellPhone").inputmask("option", "onBeforePaste")
@@ -588,7 +595,7 @@ Change the mask placeholder
 
 ```javascript
 $(document).ready(function(){
-   $("#date").inputmask("d/m/y",{ "placeholder": "*" });
+  $("#date").inputmask("d/m/y",{ "placeholder": "*" });
 });
 ```
 
@@ -596,43 +603,43 @@ or a multi-char placeholder
 
 ```javascript
 $(document).ready(function(){
-   $("#date").inputmask("d/m/y",{ "placeholder": "dd/mm/yyyy" });
+  $("#date").inputmask("d/m/y",{ "placeholder": "dd/mm/yyyy" });
 });
 ```
 
 ### optionalmarker
-Definition of the symbols used to indicate an optional part in the mask.  
+Definition of the symbols used to indicate an optional part in the mask.
 
 ```javascript
-optionalmarker: { start: "[", end: "]" },
+optionalmarker: { start: "[", end: "]" }
 ```
 
 ### quantifiermarker
-Definition of the symbols used to indicate a quantifier in the mask.  
+Definition of the symbols used to indicate a quantifier in the mask.
 
 ```javascript
-quantifiermarker: { start: "{", end: "}" },
+quantifiermarker: { start: "{", end: "}" }
 ```
 
 ### groupmarker
-Definition of the symbols used to indicate a group in the mask.  
+Definition of the symbols used to indicate a group in the mask.
 
 ```javascript
-groupmarker: { start: "(", end: ")" },
+groupmarker: { start: "(", end: ")" }
 ```
 
 ### alternatormarker
-Definition of the symbols used to indicate an alternator part in the mask.  
+Definition of the symbols used to indicate an alternator part in the mask.
 
 ```javascript
-alternatormarker: "|",
+alternatormarker: "|"
 ```
 
 ### escapeChar
-Definition of the symbols used to escape a part in the mask.  
+Definition of the symbols used to escape a part in the mask.
 
 ```javascript
-escapeChar: "\\",
+escapeChar: "\\"
 ```
 
 See **escape special mask chars**
@@ -645,7 +652,7 @@ Execute a function when the mask is completed
 
 ```javascript
 $(document).ready(function(){
-   $("#date").inputmask("d/m/y",{ "oncomplete": function(){ alert('inputmask complete'); } });
+  $("#date").inputmask("d/m/y",{ "oncomplete": function(){ alert('inputmask complete'); } });
 });
 ```
 
@@ -654,7 +661,7 @@ Execute a function when the mask is incomplete.  Executes on blur.
 
 ```javascript
 $(document).ready(function(){
-   $("#date").inputmask("d/m/y",{ "onincomplete": function(){ alert('inputmask incomplete'); } });
+  $("#date").inputmask("d/m/y",{ "onincomplete": function(){ alert('inputmask incomplete'); } });
 });
 ```
 
@@ -663,7 +670,7 @@ Execute a function when the mask is cleared.
 
 ```javascript
 $(document).ready(function(){
-   $("#date").inputmask("d/m/y",{ "oncleared": function(){ alert('inputmask cleared'); } });
+  $("#date").inputmask("d/m/y",{ "oncleared": function(){ alert('inputmask cleared'); } });
 });
 ```
 
@@ -672,7 +679,7 @@ Mask repeat function. Repeat the mask definition x-times.
 
 ```javascript
 $(document).ready(function(){
-   $("#number").inputmask({ "mask": "9", "repeat": 10 });  // ~ mask "9999999999"
+  $("#number").inputmask({ "mask": "9", "repeat": 10 });  // ~ mask "9999999999"
 });
 ```
 
@@ -681,7 +688,7 @@ Toggle to allocate as much possible or the opposite. Non-greedy repeat function.
 
 ```javascript
 $(document).ready(function(){
-   $("#number").inputmask({ "mask": "9", "repeat": 10, "greedy": false });  // ~ mask "9" or mask "99" or ... mask "9999999999"
+  $("#number").inputmask({ "mask": "9", "repeat": 10, "greedy": false });  // ~ mask "9" or mask "99" or ... mask "9999999999"
 });
 ```
 
@@ -700,7 +707,7 @@ Remove the empty mask on blur or when not empty removes the optional trailing pa
 
 ```javascript
 $(document).ready(function(){
-    $("#ssn").inputmask("999-99-9999",{placeholder:" ", clearMaskOnLostFocus: true }); //default
+  $("#ssn").inputmask("999-99-9999",{placeholder:" ", clearMaskOnLostFocus: true }); //default
 });
 ```
 
@@ -712,7 +719,7 @@ Clear the incomplete input on blur
 
 ```javascript
 $(document).ready(function(){
-   $("#date").inputmask("d/m/y",{ "clearIncomplete": true } });
+  $("#date").inputmask("d/m/y",{ "clearIncomplete": true } });
 });
 ```
 
@@ -730,32 +737,32 @@ Some examples can be found in jquery.inputmask.xxx.extensions.js
 use:
 
 ```javascript
-   $("#date").inputmask("date");
+$("#date").inputmask("date");
 ```
 
 or
 
 ```javascript
-   $("#date").inputmask({ alias: "date"});
+$("#date").inputmask({ alias: "date"});
 ```
 
 You can also call an alias and extend it with some more options
 
 ```javascript
-   $("#date").inputmask("date", { "clearIncomplete": true });
+$("#date").inputmask("date", { "clearIncomplete": true });
 ```
 
 or
 
 ```javascript
-   $("#date").inputmask({ alias: "date", "clearIncomplete": true });
+$("#date").inputmask({ alias: "date", "clearIncomplete": true });
 ```
 
 ### alias
 The alias to use.
 
 ```javascript
-   $("#date").inputmask({ alias: "email"});
+$("#date").inputmask({ alias: "email"});
 ```
 
 ### onKeyDown
@@ -770,16 +777,16 @@ Function arguments: initialValue, opts<br>Function return: processedValue
 
 ```javascript
 $(selector).inputmask({
-                alias: 'phonebe',
-                onBeforeMask: function (value, opts) {
-                                 var processedValue = value.replace(/^0/g, "");
-                                if (processedValue.indexOf("32") > 1 ||     processedValue.indexOf("32") == -1) {
-                                    processedValue = "32" + processedValue;
-                                }
+  alias: 'phonebe',
+  onBeforeMask: function (value, opts) {
+    var processedValue = value.replace(/^0/g, "");
+    if (processedValue.indexOf("32") > 1 ||     processedValue.indexOf("32") == -1) {
+      processedValue = "32" + processedValue;
+    }
 
-                                return processedValue;
-                            }
-            });
+    return processedValue;
+  }
+});
 ```
 
 ### onBeforePaste
@@ -789,18 +796,18 @@ Function arguments: pastedValue, opts<br>Function return: processedValue
 
 ```javascript
 $(selector).inputmask({
-                mask: '9999 9999 9999 9999',
-                placeholder: ' ',
-                showMaskOnHover: false,
-                showMaskOnFocus: false,
-                onBeforePaste: function (pastedValue, opts) {
-                    var processedValue = pastedValue;
+  mask: '9999 9999 9999 9999',
+  placeholder: ' ',
+  showMaskOnHover: false,
+  showMaskOnFocus: false,
+  onBeforePaste: function (pastedValue, opts) {
+    var processedValue = pastedValue;
 
-                    //do something with it
+    //do something with it
 
-                    return processedValue;
-                }
-            });
+    return processedValue;
+  }
+});
 ```
 
 You can also disable pasting a value by returning false in the onBeforePaste call.
@@ -821,10 +828,10 @@ Function arguments: maskedValue, unmaskedValue<br>Function return: processedValu
 
 ```javascript
 $(document).ready(function(){
-   $("#number").inputmask("decimal", { onUnMask: function(maskedValue, unmaskedValue) {
-        //do something with the value
-        return unmaskedValue;
-   }});
+  $("#number").inputmask("decimal", { onUnMask: function(maskedValue, unmaskedValue) {
+    //do something with the value
+    return unmaskedValue;
+  }});
 });
 ```
 
@@ -833,7 +840,7 @@ Shows the mask when the input gets focus. (default = true)
 
 ```javascript
 $(document).ready(function(){
-    $("#ssn").inputmask("999-99-9999",{ showMaskOnFocus: true }); //default
+  $("#ssn").inputmask("999-99-9999",{ showMaskOnFocus: true }); //default
 });
 ```
 
@@ -844,7 +851,7 @@ Shows the mask when hovering the mouse. (default = true)
 
 ```javascript
 $(document).ready(function(){
-    $("#ssn").inputmask("999-99-9999",{ showMaskOnHover: true }); //default
+  $("#ssn").inputmask("999-99-9999",{ showMaskOnHover: true }); //default
 });
 ```
 
@@ -853,10 +860,11 @@ Callback function is executed on every keyvalidation with the key & result as pa
 
 ```javascript
 $(document).ready(function(){
-    $("#ssn").inputmask("999-99-9999",
-            { onKeyValidation: function (key, result) {
-                                console.log(key + " - " + result);
-                                } });
+  $("#ssn").inputmask("999-99-9999", {
+    onKeyValidation: function (key, result) {
+      console.log(key + " - " + result);
+    }
+  });
 });
 ```
 
@@ -865,7 +873,7 @@ $(document).ready(function(){
 Show the current mask definition as a tooltip.
 
 ```javascript
-  $(selector).inputmask({ mask: ["999-999-9999 [x99999]", "+099 99 99 9999[9]-9999"], showTooltip: true });
+$(selector).inputmask({ mask: ["999-999-9999 [x99999]", "+099 99 99 9999[9]-9999"], showTooltip: true });
 ```
 
 ### tooltip
@@ -876,7 +884,7 @@ Numeric input direction.  Keeps the caret at the end.
 
 ```javascript
 $(document).ready(function(){
-    $(selector).inputmask('€ 999.999.999,99', { numericInput: true });    //123456  =>  € ___.__1.234,56
+  $(selector).inputmask('€ 999.999.999,99', { numericInput: true });    //123456  =>  € ___.__1.234,56
 });
 ```
 
@@ -887,7 +895,7 @@ By setting the rightAlign you can specify to right align an inputmask. This is o
 
 ```javascript
 $(document).ready(function(){
-    $(selector).inputmask('decimal', { rightAlign: false });  //disables the right alignment of the decimal input
+  $(selector).inputmask('decimal', { rightAlign: false });  //disables the right alignment of the decimal input
 });
 ```
 
@@ -931,10 +939,10 @@ With this call-in (hook) you can override the default implementation of the isCo
 
 ```javascript
 $(selector).inputmask("Regex", {
-    regex: "[0-9]*",
-    isComplete: function(buffer, opts) {
-        return new RegExp(opts.regex).test(buffer.join(''));
-    }
+  regex: "[0-9]*",
+  isComplete: function(buffer, opts) {
+    return new RegExp(opts.regex).test(buffer.join(''));
+  }
 });
 ```
 
@@ -949,7 +957,7 @@ The staticDefinitionSymbol option is used to indicate that the static entries in
 
 In the example below we mark the spaces as a possible match for the "i" definition.  By doing so the mask can alternate to the second mask even when we typed already "12 3".
 
-```javaScript
+```javascript
 Inputmask("(99 99 999999)|(i{+})", {
   definitions: {
     "i": {
@@ -968,10 +976,10 @@ this can be done with the traditional jquery.val function (all browsers) or Java
 
 ```javascript
 $(document).ready(function(){
-   $("#number").val(12345);
+  $("#number").val(12345);
 
-   var number = document.getElementById("number");
-   number.value = 12345;
+  var number = document.getElementById("number");
+  number.value = 12345;
 });
 ```
 
@@ -979,11 +987,11 @@ with the autoUnmaskoption you can change the return of $.fn.val (or value proper
 
 ```javascript
 $(document).ready(function(){
-       $('#<%= tbDate.ClientID%>').inputmask({ "mask": "d/m/y", 'autoUnmask' : true});    //  value: 23/03/1973
-    alert($('#<%= tbDate.ClientID%>').val());    // shows 23031973     (autoUnmask: true)
+  $('#<%= tbDate.ClientID%>').inputmask({ "mask": "d/m/y", 'autoUnmask' : true});    //  value: 23/03/1973
+  alert($('#<%= tbDate.ClientID%>').val());    // shows 23031973     (autoUnmask: true)
 
-    var tbDate = document.getElementById("<%= tbDate.ClientID%>");
-    alert(tbDate.value);    // shows 23031973     (autoUnmask: true)
+  var tbDate = document.getElementById("<%= tbDate.ClientID%>");
+  alert(tbDate.value);    // shows 23031973     (autoUnmask: true)
 });
 ```
 
@@ -991,7 +999,7 @@ $(document).ready(function(){
 
 ```javascript
 $(document).ready(function(){
-    $("#months").inputmask("m \\months");
+  $("#months").inputmask("m \\months");
 });
 ```
 
@@ -999,25 +1007,25 @@ $(document).ready(function(){
 You can define within a definition to automatically lowercase or uppercase the entry in an input by giving the casing.<br>Casing can be null, "upper" or "lower"
 
 ```javascript
-   Inputmask.extendDefinitions({
-        'A': {
-            validator: "[A-Za-z]",
-            cardinality: 1,
-            casing: "upper" //auto uppercasing
-        },
-        '+': {
-            validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
-            cardinality: 1,
-            casing: "upper"
-        }
-    });
+Inputmask.extendDefinitions({
+  'A': {
+    validator: "[A-Za-z]",
+    cardinality: 1,
+    casing: "upper" //auto uppercasing
+  },
+  '+': {
+    validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
+    cardinality: 1,
+    casing: "upper"
+  }
+});
 ```
 
 Include jquery.inputmask.extensions.js for using the A and # definitions.
 
 ```javascript
 $(document).ready(function(){
-   $("#test").inputmask("999-AAA");    //   => 123abc ===> 123-ABC
+  $("#test").inputmask("999-AAA");    //   => 123abc ===> 123-ABC
 });
 ```
 
@@ -1056,7 +1064,7 @@ You can also apply an inputmask by using the data-inputmask attribute.  In the a
 
 ```javascript
 $(document).ready(function(){
-    $(":input").inputmask();
+  $(":input").inputmask();
 });
 ```
 
@@ -1069,7 +1077,7 @@ All options can also be passed through data-attributes.
 
 ```javascript
 $(document).ready(function(){
-    $(":input").inputmask();
+  $(":input").inputmask();
 });
 ```
 

+ 5 - 5
js/inputmask.js

@@ -728,11 +728,11 @@
 		}
 
 		var ua = navigator.userAgent,
-			iemobile = ua.match(new RegExp("iemobile", "i")) !== null,
-			iphone = (ua.match(new RegExp("iphone", "i")) !== null) && !iemobile,
-			android = (ua.match(new RegExp("android.*safari.*", "i")) !== null) && !iemobile,
-			androidchrome = ua.match(new RegExp("android.*chrome.*", "i")) !== null,
-			androidfirefox = ua.match(new RegExp("android.*firefox.*", "i")) !== null,
+			iemobile = /iemobile/i.test(ua),
+			iphone = /iphone/i.test(ua) && !iemobile,
+			android = /android.*safari.*/i.test(ua) && !iemobile,
+			androidchrome = /android.*chrome.*/i.test(ua),
+			androidfirefox = /android.*firefox.*/i.test(ua),
 			kindle = /Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua),
 			PasteEventType = isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange";