浏览代码

How to get unmask value in MVC controller (int) #524

Robin Herbots 11 年之前
父节点
当前提交
ec9d3c85f9

+ 2 - 0
README.md

@@ -345,6 +345,8 @@ $(document).ready(function(){
 With the non-greedy option set to false, you can specify * as repeat.  This makes an endless repeat.
 
 #### autoUnmask
+#### removeMaskOnSubmit
+Remove the mask before submitting the form.  Use in combination with autoUnmask: true
 #### clearMaskOnLostFocus
 
 Remove the empty mask on blur or when not empty removes the optional trailing part

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.0.52",
+  "version": "3.0.53",
   "main": "./dist/jquery.inputmask.bundle.js",
   "keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 3
 build.minor = 0
-build.revision = 52
+build.revision = 53
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.52
+* Version: 3.0.53
 */
 
 (function ($) {
@@ -742,8 +742,8 @@
             function truncateInput(inputValue) {
                 return inputValue.replace(new RegExp("(" + escapeRegex(getBufferTemplate().join('')) + ")*$"), "");
             }
-            function unmaskedvalue($input, skipDatepickerCheck) {
-                if ($input.data('_inputmask') && (skipDatepickerCheck === true || !$input.hasClass('hasDatepicker'))) {
+            function unmaskedvalue($input) {
+                if ($input.data('_inputmask') && !$input.hasClass('hasDatepicker')) {
                     var umValue = [], vps = getMaskSet()["validPositions"];
                     for (var pndx in vps) {
                         if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
@@ -1294,6 +1294,9 @@
                         if (valueOnFocus != getBuffer().join('')) {
                             $el.change();
                         }
+                        if (opts.autoUnmask && opts.removeMaskOnSubmit) {
+                            $el.inputmask("remove");
+                        }
                     }).bind('reset', function () {
                         setTimeout(function () {
                             $el.trigger("setvalue");
@@ -1448,7 +1451,7 @@
                         maskset = $el.data('_inputmask')['maskset'];
                         opts = $el.data('_inputmask')['opts'];
                         isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
-                        return unmaskedvalue(actionObj["$input"], actionObj["skipDatepickerCheck"]);
+                        return unmaskedvalue(actionObj["$input"]);
                     case "mask":
                         valueOnFocus = getBuffer().join('');
                         mask(actionObj["el"]);
@@ -1546,6 +1549,7 @@
                 repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
                 greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                 autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
+                removeMaskOnSubmit: false, //remove the mask before submitting the form.  Use in combination with autoUnmask: true
                 clearMaskOnLostFocus: true,
                 insertMode: true, //insert the input or overwrite the input
                 clearIncomplete: false, //clear the incomplete input on blur
@@ -1722,7 +1726,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.52
+* Version: 3.0.53
 */
 
 (function ($) {
@@ -2085,7 +2089,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.52
+Version: 3.0.53
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2206,7 +2210,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.52
+Version: 3.0.53
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2669,7 +2673,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.52
+Version: 3.0.53
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2860,7 +2864,7 @@ Optional extensions on the jquery.inputmask base
                 var processValue = maskedValue.replace(opts.prefix, "");
                 processValue = processValue.replace(opts.suffix, "");
                 processValue = processValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), "");
-                processValue = processValue.replace($.inputmask.escapeRegex.call(this, opts.radixPoint), ".");
+                //processValue = processValue.replace($.inputmask.escapeRegex.call(this, opts.radixPoint), ".");
                 return processValue;
             },
             isComplete: function (buffer, opts) {
@@ -2910,7 +2914,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.52
+Version: 3.0.53
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -3097,7 +3101,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.52
+Version: 3.0.53
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

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


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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"mask"
     ],
-    "version": "3.0.52",
+    "version": "3.0.53",
     "author": {
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 7 - 3
js/jquery.inputmask.js

@@ -742,8 +742,8 @@
             function truncateInput(inputValue) {
                 return inputValue.replace(new RegExp("(" + escapeRegex(getBufferTemplate().join('')) + ")*$"), "");
             }
-            function unmaskedvalue($input, skipDatepickerCheck) {
-                if ($input.data('_inputmask') && (skipDatepickerCheck === true || !$input.hasClass('hasDatepicker'))) {
+            function unmaskedvalue($input) {
+                if ($input.data('_inputmask') && !$input.hasClass('hasDatepicker')) {
                     var umValue = [], vps = getMaskSet()["validPositions"];
                     for (var pndx in vps) {
                         if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
@@ -1294,6 +1294,9 @@
                         if (valueOnFocus != getBuffer().join('')) {
                             $el.change();
                         }
+                        if (opts.autoUnmask && opts.removeMaskOnSubmit) {
+                            $el.inputmask("remove");
+                        }
                     }).bind('reset', function () {
                         setTimeout(function () {
                             $el.trigger("setvalue");
@@ -1448,7 +1451,7 @@
                         maskset = $el.data('_inputmask')['maskset'];
                         opts = $el.data('_inputmask')['opts'];
                         isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
-                        return unmaskedvalue(actionObj["$input"], actionObj["skipDatepickerCheck"]);
+                        return unmaskedvalue(actionObj["$input"]);
                     case "mask":
                         valueOnFocus = getBuffer().join('');
                         mask(actionObj["el"]);
@@ -1546,6 +1549,7 @@
                 repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
                 greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                 autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
+                removeMaskOnSubmit: false, //remove the mask before submitting the form.  Use in combination with autoUnmask: true
                 clearMaskOnLostFocus: true,
                 insertMode: true, //insert the input or overwrite the input
                 clearIncomplete: false, //clear the incomplete input on blur

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

@@ -194,7 +194,7 @@ Optional extensions on the jquery.inputmask base
                 var processValue = maskedValue.replace(opts.prefix, "");
                 processValue = processValue.replace(opts.suffix, "");
                 processValue = processValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), "");
-                processValue = processValue.replace($.inputmask.escapeRegex.call(this, opts.radixPoint), ".");
+                //processValue = processValue.replace($.inputmask.escapeRegex.call(this, opts.radixPoint), ".");
                 return processValue;
             },
             isComplete: function (buffer, opts) {