浏览代码

add masking the textcontent of a div fix #734

Robin Herbots 10 年之前
父节点
当前提交
ddbc61fb5c

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
 
 
 ## [Unreleased][unreleased]
 ## [Unreleased][unreleased]
 ### Added
 ### Added
+- enable masking the text content in a div
 - enable contenteditable elements for inputmask
 - enable contenteditable elements for inputmask
 - Update Command object to handle inserts and allow for multiple removes
 - Update Command object to handle inserts and allow for multiple removes
 - Add a change log
 - Add a change log

+ 2 - 1
README.md

@@ -85,7 +85,8 @@ $(document).ready(function(){
 
 
 - input type="text" 
 - input type="text" 
 - input type="tel"
 - input type="tel"
-- div contenteditable="true" (and all others supported by contenteditable, but not tested)
+- div contenteditable="true" (and all others supported by contenteditable)
+- div (mask text content or set maskedvalue with jQuery.val)
 
 
 #### Default masking definitions
 #### Default masking definitions
 
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.1.62-16",
+  "version": "3.1.62-17",
   "main": [
   "main": [
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.extensions.js",
     "./dist/inputmask/jquery.inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
     "name": "jquery_inputmask",
     "name": "jquery_inputmask",
     "repository": "robinherbots/jquery.inputmask",
     "repository": "robinherbots/jquery.inputmask",
     "description": "jquery.inputmask is a jquery plugin which create an input mask.",
     "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-    "version": "3.1.62-16",
+    "version": "3.1.62-17",
     "keywords": [ "jquery", "plugins", "input", "form", "inputmask", "mask" ],
     "keywords": [ "jquery", "plugins", "input", "form", "inputmask", "mask" ],
     "main": "./dist/jquery.inputmask.bundle.js",
     "main": "./dist/jquery.inputmask.bundle.js",
     "scripts": [
     "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
 {
     "name": "robinherbots/jquery.inputmask",
     "name": "robinherbots/jquery.inputmask",
     "description": "jquery.inputmask is a jquery plugin which create an input mask.",
     "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-	"version": "3.1.62-16",
+	"version": "3.1.62-17",
     "type": "library",
     "type": "library",
     "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
     "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
     "homepage": "http://robinherbots.github.io/jquery.inputmask",
     "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/jquery.inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.date.extensions.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.extensions.min.js


+ 11 - 10
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : factory(jQuery);
@@ -760,7 +760,7 @@
             }
             }
             var valueGet, valueSet;
             var valueGet, valueSet;
             if (!npt._valueGet) {
             if (!npt._valueGet) {
-                Object.getOwnPropertyDescriptor && void 0 == npt.value && npt.isContentEditable ? (valueGet = function() {
+                Object.getOwnPropertyDescriptor && void 0 == npt.value ? (valueGet = function() {
                     return this.textContent;
                     return this.textContent;
                 }, valueSet = function(value) {
                 }, valueSet = function(value) {
                     this.textContent = value;
                     this.textContent = value;
@@ -921,7 +921,7 @@
         }
         }
         function compositionEndEvent() {}
         function compositionEndEvent() {}
         function mask(el) {
         function mask(el) {
-            if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type")) || el.isContentEditable) {
+            if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type")) || el.isContentEditable || $el.is("div")) {
                 if ($el.data("_inputmask", {
                 if ($el.data("_inputmask", {
                     maskset: maskset,
                     maskset: maskset,
                     opts: opts,
                     opts: opts,
@@ -932,7 +932,7 @@
                     var inputData = $el.data("_inputmask");
                     var inputData = $el.data("_inputmask");
                     inputData.isRTL = !0, $el.data("_inputmask", inputData), isRTL = !0;
                     inputData.isRTL = !0, $el.data("_inputmask", inputData), isRTL = !0;
                 }
                 }
-                $el.unbind(".inputmask"), $el.closest("form").bind("submit", function() {
+                $el.unbind(".inputmask"), $el.is(":input") && el.isContentEditable && ($el.closest("form").bind("submit", function() {
                     undoValue != getBuffer().join("") && $el.change(), $el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join("") && $el[0]._valueSet(""), 
                     undoValue != getBuffer().join("") && $el.change(), $el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join("") && $el[0]._valueSet(""), 
                     opts.removeMaskOnSubmit && $el.inputmask("remove");
                     opts.removeMaskOnSubmit && $el.inputmask("remove");
                 }).bind("reset", function() {
                 }).bind("reset", function() {
@@ -978,11 +978,7 @@
                     setTimeout(function() {
                     setTimeout(function() {
                         caret(input, 0, seekNext(getLastValidPosition()));
                         caret(input, 0, seekNext(getLastValidPosition()));
                     }, 0);
                     }, 0);
-                }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent).bind("setvalue.inputmask", function() {
-                    var input = this, value = input._valueGet();
-                    input._valueSet($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(input, value, opts) || value : value), 
-                    checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join("") && input._valueSet("");
-                }).bind("cut.inputmask", function(e) {
+                }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent).bind("cut.inputmask", function(e) {
                     skipInputEvent = !0;
                     skipInputEvent = !0;
                     var input = this, $input = $(input), pos = caret(input);
                     var input = this, $input = $(input), pos = caret(input);
                     handleRemove(input, $.inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")), 
                     handleRemove(input, $.inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")), 
@@ -991,7 +987,12 @@
                 }).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared), 
                 }).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared), 
                 $el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent), 
                 $el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent), 
                 androidfirefox || $el.bind("compositionstart.inputmask", compositionStartEvent).bind("compositionupdate.inputmask", compositionUpdateEvent).bind("compositionend.inputmask", compositionEndEvent), 
                 androidfirefox || $el.bind("compositionstart.inputmask", compositionStartEvent).bind("compositionupdate.inputmask", compositionUpdateEvent).bind("compositionend.inputmask", compositionEndEvent), 
-                "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent), patchValueProperty(el);
+                "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent)), 
+                $el.bind("setvalue.inputmask", function() {
+                    var input = this, value = input._valueGet();
+                    input._valueSet($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(input, value, opts) || value : value), 
+                    checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join("") && input._valueSet("");
+                }), patchValueProperty(el);
                 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
                 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
                 checkVal(el, !0, !1, initialValue.split(""));
                 checkVal(el, !0, !1, initialValue.split(""));
                 var buffer = getBuffer().slice();
                 var buffer = getBuffer().slice();

文件差异内容过多而无法显示
+ 2 - 2
dist/inputmask/jquery.inputmask.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.numeric.extensions.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.phone.extensions.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.regex.extensions.min.js


+ 11 - 10
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Copyright (c) 2010 - 2015 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: 3.1.62-16
+* Version: 3.1.62-17
 */
 */
 !function($) {
 !function($) {
     function isInputEventSupported(eventName) {
     function isInputEventSupported(eventName) {
@@ -758,7 +758,7 @@
             }
             }
             var valueGet, valueSet;
             var valueGet, valueSet;
             if (!npt._valueGet) {
             if (!npt._valueGet) {
-                Object.getOwnPropertyDescriptor && void 0 == npt.value && npt.isContentEditable ? (valueGet = function() {
+                Object.getOwnPropertyDescriptor && void 0 == npt.value ? (valueGet = function() {
                     return this.textContent;
                     return this.textContent;
                 }, valueSet = function(value) {
                 }, valueSet = function(value) {
                     this.textContent = value;
                     this.textContent = value;
@@ -919,7 +919,7 @@
         }
         }
         function compositionEndEvent() {}
         function compositionEndEvent() {}
         function mask(el) {
         function mask(el) {
-            if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type")) || el.isContentEditable) {
+            if ($el = $(el), $el.is(":input") && isInputTypeSupported($el.attr("type")) || el.isContentEditable || $el.is("div")) {
                 if ($el.data("_inputmask", {
                 if ($el.data("_inputmask", {
                     maskset: maskset,
                     maskset: maskset,
                     opts: opts,
                     opts: opts,
@@ -930,7 +930,7 @@
                     var inputData = $el.data("_inputmask");
                     var inputData = $el.data("_inputmask");
                     inputData.isRTL = !0, $el.data("_inputmask", inputData), isRTL = !0;
                     inputData.isRTL = !0, $el.data("_inputmask", inputData), isRTL = !0;
                 }
                 }
-                $el.unbind(".inputmask"), $el.closest("form").bind("submit", function() {
+                $el.unbind(".inputmask"), $el.is(":input") && el.isContentEditable && ($el.closest("form").bind("submit", function() {
                     undoValue != getBuffer().join("") && $el.change(), $el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join("") && $el[0]._valueSet(""), 
                     undoValue != getBuffer().join("") && $el.change(), $el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join("") && $el[0]._valueSet(""), 
                     opts.removeMaskOnSubmit && $el.inputmask("remove");
                     opts.removeMaskOnSubmit && $el.inputmask("remove");
                 }).bind("reset", function() {
                 }).bind("reset", function() {
@@ -976,11 +976,7 @@
                     setTimeout(function() {
                     setTimeout(function() {
                         caret(input, 0, seekNext(getLastValidPosition()));
                         caret(input, 0, seekNext(getLastValidPosition()));
                     }, 0);
                     }, 0);
-                }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent).bind("setvalue.inputmask", function() {
-                    var input = this, value = input._valueGet();
-                    input._valueSet($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(input, value, opts) || value : value), 
-                    checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join("") && input._valueSet("");
-                }).bind("cut.inputmask", function(e) {
+                }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent).bind("cut.inputmask", function(e) {
                     skipInputEvent = !0;
                     skipInputEvent = !0;
                     var input = this, $input = $(input), pos = caret(input);
                     var input = this, $input = $(input), pos = caret(input);
                     handleRemove(input, $.inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")), 
                     handleRemove(input, $.inputmask.keyCode.DELETE, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue != getBuffer().join("")), 
@@ -989,7 +985,12 @@
                 }).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared), 
                 }).bind("complete.inputmask", opts.oncomplete).bind("incomplete.inputmask", opts.onincomplete).bind("cleared.inputmask", opts.oncleared), 
                 $el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent), 
                 $el.bind("keydown.inputmask", keydownEvent).bind("keypress.inputmask", keypressEvent), 
                 androidfirefox || $el.bind("compositionstart.inputmask", compositionStartEvent).bind("compositionupdate.inputmask", compositionUpdateEvent).bind("compositionend.inputmask", compositionEndEvent), 
                 androidfirefox || $el.bind("compositionstart.inputmask", compositionStartEvent).bind("compositionupdate.inputmask", compositionUpdateEvent).bind("compositionend.inputmask", compositionEndEvent), 
-                "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent), patchValueProperty(el);
+                "paste" === PasteEventType && $el.bind("input.inputmask", inputFallBackEvent)), 
+                $el.bind("setvalue.inputmask", function() {
+                    var input = this, value = input._valueGet();
+                    input._valueSet($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(input, value, opts) || value : value), 
+                    checkVal(input, !0, !1), undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join("") && input._valueSet("");
+                }), patchValueProperty(el);
                 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
                 var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(el, el._valueGet(), opts) || el._valueGet() : el._valueGet();
                 checkVal(el, !0, !1, initialValue.split(""));
                 checkVal(el, !0, !1, initialValue.split(""));
                 var buffer = getBuffer().slice();
                 var buffer = getBuffer().slice();

文件差异内容过多而无法显示
+ 2 - 2
dist/jquery.inputmask.bundle.min.js


+ 129 - 124
js/jquery.inputmask.js

@@ -1318,7 +1318,7 @@
 
 
                 if (!npt._valueGet) {
                 if (!npt._valueGet) {
                     var valueProperty;
                     var valueProperty;
-                    if (Object.getOwnPropertyDescriptor && npt.value == undefined && npt.isContentEditable) {
+                    if (Object.getOwnPropertyDescriptor && npt.value == undefined){ // && npt.isContentEditable) {
                         valueGet = function () {
                         valueGet = function () {
                             return this.textContent;
                             return this.textContent;
                         }
                         }
@@ -1672,7 +1672,7 @@
             }
             }
             function mask(el) {
             function mask(el) {
                 $el = $(el);
                 $el = $(el);
-                if (($el.is(":input") && isInputTypeSupported($el.attr("type"))) || el.isContentEditable) {
+                if (($el.is(":input") && isInputTypeSupported($el.attr("type"))) || el.isContentEditable || $el.is("div")) {
                     //store tests & original buffer in the input element - used to get the unmasked value
                     //store tests & original buffer in the input element - used to get the unmasked value
                     $el.data('_inputmask', {
                     $el.data('_inputmask', {
                         'maskset': maskset,
                         'maskset': maskset,
@@ -1699,151 +1699,156 @@
 
 
                     //unbind all events - to make sure that no other mask will interfere when re-masking
                     //unbind all events - to make sure that no other mask will interfere when re-masking
                     $el.unbind(".inputmask");
                     $el.unbind(".inputmask");
-                    //bind events
-                    $el.closest('form').bind("submit", function (e) { //trigger change on submit if any
-                        if (undoValue != getBuffer().join('')) {
-                            $el.change();
-                        }
-                        if ($el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join('')) {
-                            $el[0]._valueSet(''); //clear masktemplete on submit and still has focus
-                        }
-                        if (opts.removeMaskOnSubmit) {
-                            $el.inputmask("remove");
-                        }
-                    }).bind('reset', function () {
-                        setTimeout(function () {
-                            $el.triggerHandler('setvalue.inputmask');
-                        }, 0);
-                    });
-                    $el.bind("mouseenter.inputmask", function () {
-                        var $input = $(this), input = this;
-                        if (!$input.is(":focus") && opts.showMaskOnHover) {
-                            if (input._valueGet() != getBuffer().join('')) {
-                                writeBuffer(input, getBuffer());
+
+                    if ($el.is(":input") && el.isContentEditable) {
+                        //bind events
+                        $el.closest('form').bind("submit", function (e) { //trigger change on submit if any
+                            if (undoValue != getBuffer().join('')) {
+                                $el.change();
                             }
                             }
-                        }
-                    }).bind("blur.inputmask", function (e) {
-                        var $input = $(this), input = this;
-                        if ($input.data('_inputmask')) {
-                            var nptValue = input._valueGet(), buffer = getBuffer().slice();
-                            firstClick = true;
-                            if (undoValue != buffer.join('')) {
-                                setTimeout(function () { //change event should be triggered after the other buffer manipulations on blur
-                                    $input.change();
-                                    undoValue = buffer.join('');
-                                }, 0);
+                            if ($el[0]._valueGet && $el[0]._valueGet() == getBufferTemplate().join('')) {
+                                $el[0]._valueSet(''); //clear masktemplete on submit and still has focus
                             }
                             }
-                            if (nptValue != '') {
-                                if (opts.clearMaskOnLostFocus) {
-                                    if (nptValue == getBufferTemplate().join(''))
-                                        buffer = [];
-                                    else { //clearout optional tail of the mask
-                                        clearOptionalTail(buffer);
-                                    }
+                            if (opts.removeMaskOnSubmit) {
+                                $el.inputmask("remove");
+                            }
+                        }).bind('reset', function () {
+                            setTimeout(function () {
+                                $el.triggerHandler('setvalue.inputmask');
+                            }, 0);
+                        });
+                        $el.bind("mouseenter.inputmask", function () {
+                            var $input = $(this), input = this;
+                            if (!$input.is(":focus") && opts.showMaskOnHover) {
+                                if (input._valueGet() != getBuffer().join('')) {
+                                    writeBuffer(input, getBuffer());
                                 }
                                 }
-                                if (isComplete(buffer) === false) {
-                                    $input.trigger("incomplete");
-                                    if (opts.clearIncomplete) {
-                                        resetMaskSet();
-                                        if (opts.clearMaskOnLostFocus)
+                            }
+                        }).bind("blur.inputmask", function (e) {
+                            var $input = $(this), input = this;
+                            if ($input.data('_inputmask')) {
+                                var nptValue = input._valueGet(), buffer = getBuffer().slice();
+                                firstClick = true;
+                                if (undoValue != buffer.join('')) {
+                                    setTimeout(function () { //change event should be triggered after the other buffer manipulations on blur
+                                        $input.change();
+                                        undoValue = buffer.join('');
+                                    }, 0);
+                                }
+                                if (nptValue != '') {
+                                    if (opts.clearMaskOnLostFocus) {
+                                        if (nptValue == getBufferTemplate().join(''))
                                             buffer = [];
                                             buffer = [];
-                                        else {
-                                            buffer = getBufferTemplate().slice();
+                                        else { //clearout optional tail of the mask
+                                            clearOptionalTail(buffer);
+                                        }
+                                    }
+                                    if (isComplete(buffer) === false) {
+                                        $input.trigger("incomplete");
+                                        if (opts.clearIncomplete) {
+                                            resetMaskSet();
+                                            if (opts.clearMaskOnLostFocus)
+                                                buffer = [];
+                                            else {
+                                                buffer = getBufferTemplate().slice();
 
 
+                                            }
                                         }
                                         }
                                     }
                                     }
-                                }
 
 
-                                writeBuffer(input, buffer, undefined, e);
+                                    writeBuffer(input, buffer, undefined, e);
+                                }
                             }
                             }
-                        }
-                    }).bind("focus.inputmask", function (e) {
-                        var $input = $(this), input = this, nptValue = input._valueGet();
-                        if (opts.showMaskOnFocus && (!opts.showMaskOnHover || (opts.showMaskOnHover && nptValue == ''))) {
-                            if (input._valueGet() != getBuffer().join('')) {
-                                writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()));
+                        }).bind("focus.inputmask", function (e) {
+                            var $input = $(this), input = this, nptValue = input._valueGet();
+                            if (opts.showMaskOnFocus && (!opts.showMaskOnHover || (opts.showMaskOnHover && nptValue == ''))) {
+                                if (input._valueGet() != getBuffer().join('')) {
+                                    writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()));
+                                }
                             }
                             }
-                        }
-                        undoValue = getBuffer().join('');
-                    }).bind("mouseleave.inputmask", function () {
-                        var $input = $(this), input = this;
-                        if (opts.clearMaskOnLostFocus) {
-                            var buffer = getBuffer().slice(), nptValue = input._valueGet();
-                            if (!$input.is(":focus") && nptValue != $input.attr("placeholder") && nptValue != '') {
-                                if (nptValue == getBufferTemplate().join(''))
-                                    buffer = [];
-                                else { //clearout optional tail of the mask
-                                    clearOptionalTail(buffer);
+                            undoValue = getBuffer().join('');
+                        }).bind("mouseleave.inputmask", function () {
+                            var $input = $(this), input = this;
+                            if (opts.clearMaskOnLostFocus) {
+                                var buffer = getBuffer().slice(), nptValue = input._valueGet();
+                                if (!$input.is(":focus") && nptValue != $input.attr("placeholder") && nptValue != '') {
+                                    if (nptValue == getBufferTemplate().join(''))
+                                        buffer = [];
+                                    else { //clearout optional tail of the mask
+                                        clearOptionalTail(buffer);
+                                    }
+                                    writeBuffer(input, buffer);
                                 }
                                 }
-                                writeBuffer(input, buffer);
                             }
                             }
-                        }
-                    }).bind("click.inputmask", function () {
-                        var $input = $(this), input = this;
-                        if ($input.is(":focus")) {
-                            var selectedCaret = caret(input);
-                            if (selectedCaret.begin == selectedCaret.end) {
-                                if (opts.radixFocus && opts.radixPoint != "" && $.inArray(opts.radixPoint, getBuffer()) != -1 && (firstClick || getBuffer().join('') == getBufferTemplate().join(''))) {
-                                    caret(input, $.inArray(opts.radixPoint, getBuffer()));
-                                    firstClick = false;
-                                } else {
-                                    var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin,
-                                        lastPosition = seekNext(getLastValidPosition(clickPosition));
-                                    if (clickPosition < lastPosition) {
-                                        caret(input, isMask(clickPosition) ? clickPosition : seekNext(clickPosition));
+                        }).bind("click.inputmask", function () {
+                            var $input = $(this), input = this;
+                            if ($input.is(":focus")) {
+                                var selectedCaret = caret(input);
+                                if (selectedCaret.begin == selectedCaret.end) {
+                                    if (opts.radixFocus && opts.radixPoint != "" && $.inArray(opts.radixPoint, getBuffer()) != -1 && (firstClick || getBuffer().join('') == getBufferTemplate().join(''))) {
+                                        caret(input, $.inArray(opts.radixPoint, getBuffer()));
+                                        firstClick = false;
                                     } else {
                                     } else {
-                                        caret(input, lastPosition);
+                                        var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin,
+                                            lastPosition = seekNext(getLastValidPosition(clickPosition));
+                                        if (clickPosition < lastPosition) {
+                                            caret(input, isMask(clickPosition) ? clickPosition : seekNext(clickPosition));
+                                        } else {
+                                            caret(input, lastPosition);
+                                        }
                                     }
                                     }
                                 }
                                 }
                             }
                             }
-                        }
-                    }).bind('dblclick.inputmask', function () {
-                        var input = this;
-                        setTimeout(function () {
-                            caret(input, 0, seekNext(getLastValidPosition()));
-                        }, 0);
-                    }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent
-                    ).bind('setvalue.inputmask', function () {
-                        var input = this, value = input._valueGet();
-                        input._valueSet($.isFunction(opts.onBeforeMask) ? (opts.onBeforeMask.call(input, value, opts) || value) : value);
-                        checkVal(input, true, false);
-                        undoValue = getBuffer().join('');
-                        if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join(''))
-                            input._valueSet('');
-                    }).bind('cut.inputmask', function (e) {
-                        skipInputEvent = true; //stop inputFallback
-                        var input = this, $input = $(input), pos = caret(input);
-
-                        handleRemove(input, $.inputmask.keyCode.DELETE, pos);
-                        writeBuffer(input, getBuffer(), getMaskSet()["p"], e, undoValue != getBuffer().join(''));
+                        }).bind('dblclick.inputmask', function () {
+                            var input = this;
+                            setTimeout(function () {
+                                caret(input, 0, seekNext(getLastValidPosition()));
+                            }, 0);
+                        }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent
+                        ).bind('cut.inputmask', function (e) {
+                            skipInputEvent = true; //stop inputFallback
+                            var input = this, $input = $(input), pos = caret(input);
+
+                            handleRemove(input, $.inputmask.keyCode.DELETE, pos);
+                            writeBuffer(input, getBuffer(), getMaskSet()["p"], e, undoValue != getBuffer().join(''));
+
+                            if (input._valueGet() == getBufferTemplate().join(''))
+                                $input.trigger('cleared');
+
+                            if (opts.showTooltip) { //update tooltip
+                                $input.prop("title", getMaskSet()["mask"]);
+                            }
+                        }).bind('complete.inputmask', opts.oncomplete
+                        ).bind('incomplete.inputmask', opts.onincomplete
+                        ).bind('cleared.inputmask', opts.oncleared);
 
 
-                        if (input._valueGet() == getBufferTemplate().join(''))
-                            $input.trigger('cleared');
+                        $el.bind("keydown.inputmask", keydownEvent
+                        ).bind("keypress.inputmask", keypressEvent);
 
 
-                        if (opts.showTooltip) { //update tooltip
-                            $input.prop("title", getMaskSet()["mask"]);
+                        if (!androidfirefox) {
+                            $el.bind("compositionstart.inputmask", compositionStartEvent
+                            ).bind("compositionupdate.inputmask", compositionUpdateEvent
+                            ).bind("compositionend.inputmask", compositionEndEvent);
                         }
                         }
-                    }).bind('complete.inputmask', opts.oncomplete
-                    ).bind('incomplete.inputmask', opts.onincomplete
-                    ).bind('cleared.inputmask', opts.oncleared);
 
 
-                    $el.bind("keydown.inputmask", keydownEvent
-                    ).bind("keypress.inputmask", keypressEvent);
-
-                    if (!androidfirefox) {
-                        $el.bind("compositionstart.inputmask", compositionStartEvent
-                        ).bind("compositionupdate.inputmask", compositionUpdateEvent
-                        ).bind("compositionend.inputmask", compositionEndEvent);
-                    }
+                        if (PasteEventType === "paste") {
+                            $el.bind("input.inputmask", inputFallBackEvent);
+                        }
 
 
-                    if (PasteEventType === "paste") {
-                        $el.bind("input.inputmask", inputFallBackEvent);
+                        //if (android || androidfirefox || androidchrome || kindle) {
+                        //    $el.unbind("input.inputmask");
+                        //    $el.bind("input.inputmask", mobileInputEvent);
+                        //}
                     }
                     }
 
 
-                    //if (android || androidfirefox || androidchrome || kindle) {
-                    //    $el.unbind("input.inputmask");
-                    //    $el.bind("input.inputmask", mobileInputEvent);
-                    //}
+                    $el.bind('setvalue.inputmask', function () {
+                        var input = this, value = input._valueGet();
+                        input._valueSet($.isFunction(opts.onBeforeMask) ? (opts.onBeforeMask.call(input, value, opts) || value) : value);
+                        checkVal(input, true, false);
+                        undoValue = getBuffer().join('');
+                        if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input._valueGet() == getBufferTemplate().join(''))
+                            input._valueSet('');
+                    });
 
 
                     patchValueProperty(el);
                     patchValueProperty(el);
 
 

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.1.62-16",
+  "version": "3.1.62-17",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "scripts": {
   "scripts": {