ソースを参照

added clearIncomplete option - clear the incomplete input on blur

Robin Herbots 14 年 前
コミット
7ec351c24e
1 ファイル変更10 行追加1 行削除
  1. 10 1
      jquery.inputmask.js

+ 10 - 1
jquery.inputmask.js

@@ -3,7 +3,7 @@ Input Mask plugin for jquery
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 0.3.6
+Version: 0.3.7
  
 This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
 */
@@ -27,6 +27,7 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
             numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
             clearMaskOnLostFocus: true,
             insertMode: true, //insert the input or overwrite the input
+            clearIncomplete: false, //clear the incomplete input on blur
             definitions: {
                 '9': {
                     "validator": "[0-9]",
@@ -455,6 +456,14 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
                     }
                     if (opts.clearMaskOnLostFocus && _val.call(input) == _buffer.join(''))
                         _val.call(input, '');
+                    if (opts.clearIncomplete && checkVal(input, buffer, true) != getMaskLength()) {
+                        if (opts.clearMaskOnLostFocus)
+                            _val.call(input, '');
+                        else {
+                            buffer = _buffer.slice();
+                            writeBuffer(input, buffer);
+                        }
+                    }
                 }).bind("focus.inputmask", function() {
                     var input = $(this);
                     input.addClass('focus.inputmask');