Browse Source

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

Robin Herbots 11 years ago
parent
commit
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.
 With the non-greedy option set to false, you can specify * as repeat.  This makes an endless repeat.
 
 
 #### autoUnmask
 #### autoUnmask
+#### removeMaskOnSubmit
+Remove the mask before submitting the form.  Use in combination with autoUnmask: true
 #### clearMaskOnLostFocus
 #### clearMaskOnLostFocus
 
 
 Remove the empty mask on blur or when not empty removes the optional trailing part
 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",
   "name": "jquery.inputmask",
-  "version": "3.0.52",
+  "version": "3.0.53",
   "main": "./dist/jquery.inputmask.bundle.js",
   "main": "./dist/jquery.inputmask.bundle.js",
   "keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
   "keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
   "description": "jquery.inputmask is a jquery plugin which create an input 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.major = 3
 build.minor = 0
 build.minor = 0
-build.revision = 52
+build.revision = 53
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.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
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 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.0.52
+* Version: 3.0.53
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -742,8 +742,8 @@
             function truncateInput(inputValue) {
             function truncateInput(inputValue) {
                 return inputValue.replace(new RegExp("(" + escapeRegex(getBufferTemplate().join('')) + ")*$"), "");
                 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"];
                     var umValue = [], vps = getMaskSet()["validPositions"];
                     for (var pndx in vps) {
                     for (var pndx in vps) {
                         if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
                         if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
@@ -1294,6 +1294,9 @@
                         if (valueOnFocus != getBuffer().join('')) {
                         if (valueOnFocus != getBuffer().join('')) {
                             $el.change();
                             $el.change();
                         }
                         }
+                        if (opts.autoUnmask && opts.removeMaskOnSubmit) {
+                            $el.inputmask("remove");
+                        }
                     }).bind('reset', function () {
                     }).bind('reset', function () {
                         setTimeout(function () {
                         setTimeout(function () {
                             $el.trigger("setvalue");
                             $el.trigger("setvalue");
@@ -1448,7 +1451,7 @@
                         maskset = $el.data('_inputmask')['maskset'];
                         maskset = $el.data('_inputmask')['maskset'];
                         opts = $el.data('_inputmask')['opts'];
                         opts = $el.data('_inputmask')['opts'];
                         isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
                         isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
-                        return unmaskedvalue(actionObj["$input"], actionObj["skipDatepickerCheck"]);
+                        return unmaskedvalue(actionObj["$input"]);
                     case "mask":
                     case "mask":
                         valueOnFocus = getBuffer().join('');
                         valueOnFocus = getBuffer().join('');
                         mask(actionObj["el"]);
                         mask(actionObj["el"]);
@@ -1546,6 +1549,7 @@
                 repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
                 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
                 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
                 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,
                 clearMaskOnLostFocus: true,
                 insertMode: true, //insert the input or overwrite the input
                 insertMode: true, //insert the input or overwrite the input
                 clearIncomplete: false, //clear the incomplete input on blur
                 clearIncomplete: false, //clear the incomplete input on blur
@@ -1722,7 +1726,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 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.0.52
+* Version: 3.0.53
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -2085,7 +2089,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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.0.52
+Version: 3.0.53
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2206,7 +2210,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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.0.52
+Version: 3.0.53
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2669,7 +2673,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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.0.52
+Version: 3.0.53
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2860,7 +2864,7 @@ Optional extensions on the jquery.inputmask base
                 var processValue = maskedValue.replace(opts.prefix, "");
                 var processValue = maskedValue.replace(opts.prefix, "");
                 processValue = processValue.replace(opts.suffix, "");
                 processValue = processValue.replace(opts.suffix, "");
                 processValue = processValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), "");
                 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;
                 return processValue;
             },
             },
             isComplete: function (buffer, opts) {
             isComplete: function (buffer, opts) {
@@ -2910,7 +2914,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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.0.52
+Version: 3.0.53
 
 
 Regex extensions on the jquery.inputmask base
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask
@@ -3097,7 +3101,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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.0.52
+Version: 3.0.53
 
 
 Phone extension.
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks
 When using this extension make sure you specify the correct url to get the masks

File diff suppressed because it is too large
+ 57 - 56
dist/jquery.inputmask.bundle.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/jquery.inputmask-multi.js


File diff suppressed because it is too large
+ 55 - 54
dist/min/jquery.inputmask.js


File diff suppressed because it is too large
+ 3 - 3
dist/min/jquery.inputmask.numeric.extensions.js


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 7 - 3
js/jquery.inputmask.js

@@ -742,8 +742,8 @@
             function truncateInput(inputValue) {
             function truncateInput(inputValue) {
                 return inputValue.replace(new RegExp("(" + escapeRegex(getBufferTemplate().join('')) + ")*$"), "");
                 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"];
                     var umValue = [], vps = getMaskSet()["validPositions"];
                     for (var pndx in vps) {
                     for (var pndx in vps) {
                         if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
                         if (vps[pndx]["match"] && vps[pndx]["match"].fn != null) {
@@ -1294,6 +1294,9 @@
                         if (valueOnFocus != getBuffer().join('')) {
                         if (valueOnFocus != getBuffer().join('')) {
                             $el.change();
                             $el.change();
                         }
                         }
+                        if (opts.autoUnmask && opts.removeMaskOnSubmit) {
+                            $el.inputmask("remove");
+                        }
                     }).bind('reset', function () {
                     }).bind('reset', function () {
                         setTimeout(function () {
                         setTimeout(function () {
                             $el.trigger("setvalue");
                             $el.trigger("setvalue");
@@ -1448,7 +1451,7 @@
                         maskset = $el.data('_inputmask')['maskset'];
                         maskset = $el.data('_inputmask')['maskset'];
                         opts = $el.data('_inputmask')['opts'];
                         opts = $el.data('_inputmask')['opts'];
                         isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
                         isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
-                        return unmaskedvalue(actionObj["$input"], actionObj["skipDatepickerCheck"]);
+                        return unmaskedvalue(actionObj["$input"]);
                     case "mask":
                     case "mask":
                         valueOnFocus = getBuffer().join('');
                         valueOnFocus = getBuffer().join('');
                         mask(actionObj["el"]);
                         mask(actionObj["el"]);
@@ -1546,6 +1549,7 @@
                 repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
                 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
                 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
                 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,
                 clearMaskOnLostFocus: true,
                 insertMode: true, //insert the input or overwrite the input
                 insertMode: true, //insert the input or overwrite the input
                 clearIncomplete: false, //clear the incomplete input on blur
                 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, "");
                 var processValue = maskedValue.replace(opts.prefix, "");
                 processValue = processValue.replace(opts.suffix, "");
                 processValue = processValue.replace(opts.suffix, "");
                 processValue = processValue.replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), "");
                 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;
                 return processValue;
             },
             },
             isComplete: function (buffer, opts) {
             isComplete: function (buffer, opts) {