Browse Source

Merge branch '2.x' into 2.6

Robin Herbots 12 years ago
parent
commit
a51b8c1f51
2 changed files with 15 additions and 1 deletions
  1. 12 0
      README.md
  2. 3 1
      js/jquery.inputmask.js

+ 12 - 0
README.md

@@ -132,6 +132,18 @@ $(document).ready(function(){
 });
 });
 ```
 ```
 
 
+### onUnMask
+Executes after unmasking to allow post-processing of the unmaskedvalue.  The arguments to the function are maskedValue, unmaskedValue.
+
+```javascript
+$(document).ready(function(){
+   $("#number").inputmask("decimal", { onUnMask: function(maskedValue, unmaskedValue) {
+		//do something with the value
+		return unmaskedValue;
+   }});
+});
+```
+
 ### set a value and apply mask
 ### set a value and apply mask
 
 
 this can be done with the traditionnal jquery.val function (all browsers) or javascript value property for browsers which implement lookupGetter or getOwnPropertyDescriptor
 this can be done with the traditionnal jquery.val function (all browsers) or javascript value property for browsers which implement lookupGetter or getOwnPropertyDescriptor

+ 3 - 1
js/jquery.inputmask.js

@@ -29,6 +29,7 @@
                 aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
                 aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
                 onKeyUp: $.noop, //override to implement autocomplete on certain keys for example
                 onKeyUp: $.noop, //override to implement autocomplete on certain keys for example
                 onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
                 onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
+                onUnMask: undefined, //executes after unmasking to allow postprocessing of the unmaskedvalue.  args => maskedValue, unmaskedValue
                 showMaskOnFocus: true, //show the mask-placeholder when the input has focus
                 showMaskOnFocus: true, //show the mask-placeholder when the input has focus
                 showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
                 showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
                 onKeyValidation: $.noop, //executes on every key-press with the result of isValid. Params: result, opts
                 onKeyValidation: $.noop, //executes on every key-press with the result of isValid. Params: result, opts
@@ -861,7 +862,8 @@
                         var umValue = $.map(getActiveBuffer(), function (element, index) {
                         var umValue = $.map(getActiveBuffer(), function (element, index) {
                             return isMask(index) && isValid(index, element, true) ? element : null;
                             return isMask(index) && isValid(index, element, true) ? element : null;
                         });
                         });
-                        return (isRTL ? umValue.reverse() : umValue).join('');
+                        var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join('');
+                        return opts.onUnMask != undefined ? opts.onUnMask.call(this, getActiveBuffer().join(''), unmaskedValue) : unmaskedValue;
                     } else {
                     } else {
                         return $input[0]._valueGet();
                         return $input[0]._valueGet();
                     }
                     }