Browse Source

Add skipOptionalPartCharacter option (issue 160)

Robin Herbots 13 years ago
parent
commit
bcdbca9188
2 changed files with 10 additions and 4 deletions
  1. 7 2
      README.md
  2. 3 2
      js/jquery.inputmask.js

+ 7 - 2
README.md

@@ -5,8 +5,6 @@ jquery.inputmask is a jquery plugin which create an input mask.
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 
 
-
-
 ## Usage:
 ## Usage:
 
 
 Include the js-files:
 Include the js-files:
@@ -181,6 +179,13 @@ Input => 12123451234      mask => (12) 12345-1234    (trigger complete)
 Input => 121234-1234      mask => (12) 1234-1234     (trigger complete)  
 Input => 121234-1234      mask => (12) 1234-1234     (trigger complete)  
 Input => 1212341234       mask => (12) 12341-234_    (trigger incomplete)  
 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.  
+
+```javascript
+skipOptionalPartCharacter: " ",
+```
+Input => 121234 1234      mask => (12) 1234-1234     (trigger complete)  
 
 
 When `clearMaskOnLostFocus: true` is set in the options (default), the mask will clearout the optional part when it is not filled in and this only in case the optional part is at the end of the mask.
 When `clearMaskOnLostFocus: true` is set in the options (default), the mask will clearout the optional part when it is not filled in and this only in case the optional part is at the end of the mask.
 
 

+ 3 - 2
js/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.0.7c
+* Version: 2.0.8
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -31,6 +31,7 @@
                 onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
                 onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
                 showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
                 showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
                 onKeyValidation: $.noop, //executes on every key-press with the result of isValid
                 onKeyValidation: $.noop, //executes on every key-press with the result of isValid
+                skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
                 //numeric basic properties
                 //numeric basic properties
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                 radixPoint: ".", // | ","
                 radixPoint: ".", // | ","
@@ -331,7 +332,7 @@
 
 
                     var maskPos = pos;
                     var maskPos = pos;
                     if (currentActiveMasksetIndex != activeMasksetIndex && !isMask(pos)) {
                     if (currentActiveMasksetIndex != activeMasksetIndex && !isMask(pos)) {
-                        if (c == activeMaskset['_buffer'][maskPos]) { //match non-mask item
+                        if (c == activeMaskset['_buffer'][maskPos] || c == opts.skipOptionalPartCharacter) { //match non-mask item
                             results[index] = { "refresh": true };  //new command hack only rewrite buffer
                             results[index] = { "refresh": true };  //new command hack only rewrite buffer
                             activeMaskset['lastValidPosition'] = maskPos;
                             activeMaskset['lastValidPosition'] = maskPos;
                             return false;
                             return false;