ソースを参照

Add skipOptionalPartCharacter option (issue 160)

Robin Herbots 13 年 前
コミット
bcdbca9188
2 ファイル変更10 行追加4 行削除
  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
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 
-
-
 ## Usage:
 
 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 => 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.
 

+ 3 - 2
js/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.0.7c
+* Version: 2.0.8
 */
 
 (function ($) {
@@ -31,6 +31,7 @@
                 onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
                 showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
                 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
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                 radixPoint: ".", // | ","
@@ -331,7 +332,7 @@
 
                     var maskPos = 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
                             activeMaskset['lastValidPosition'] = maskPos;
                             return false;