Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
RobinHerbots committed Sep 3, 2012
2 parents ba46b17 + 6553708 commit 38074533ff19a644a4e139bcf8db714610f140d0
Showing with 36 additions and 5 deletions.
  1. +15 −0 README.md
  2. +18 −3 js/jquery.inputmask.js
  3. +3 −2 js/jquery.inputmask.numeric.extensions.js
View
@@ -289,6 +289,21 @@ This can be usefull when implementing an alias, ex. decimal alias, autofill the
see jquery.inputmask.extensions.js for some examples
+### hasMaskedValue
+
+Check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
+
+```javascript
+$(document).ready(function(){
+ function validateMaskedValue(val){}
+ function validateValue(val){}
+
+ var val = $("#test").val();
+ if($("#test").inputmask("hasMaskedValue"))
+ validateMaskedValue(val);
+ else validateValue(val);
+});
+```
## Supported markup options
### RTL attribute
View
@@ -3,7 +3,7 @@
* http://github.com/RobinHerbots/jquery.inputmask
* Copyright (c) 2010 - 2012 Robin Herbots
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 1.0.21
+* Version: 1.0.22a
*/
(function ($) {
@@ -63,6 +63,7 @@
$.fn.inputmask = function (fn, options) {
var opts = $.extend(true, {}, $.inputmask.defaults, options);
+ var pasteEvent = isInputEventSupported('paste') ? 'paste' : 'input';
var iphone = navigator.userAgent.match(/iphone/i) != null;
var android = navigator.userAgent.match(/android.*mobile safari.*/i) != null;
@@ -137,6 +138,8 @@
if (this.data('inputmask'))
return this.data('inputmask')['_buffer'].join('');
else return "";
+ case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
+ return this.data('inputmask') ? !this.data('inputmask')['autoUnmask'] : false;
default:
//check if the fn is an alias
if (!resolveAlias(fn)) {
@@ -167,6 +170,18 @@
}
//helper functions
+ function isInputEventSupported(eventName) {
+ var el = document.createElement('input'),
+ eventName = 'on' + eventName,
+ isSupported = (eventName in el);
+ if (!isSupported) {
+ el.setAttribute(eventName, 'return;');
+ isSupported = typeof el[eventName] == 'function';
+ }
+ el = null;
+ return isSupported;
+ }
+
function resolveAlias(aliasStr) {
var aliasDefinition = opts.aliases[aliasStr];
if (aliasDefinition) {
@@ -636,7 +651,7 @@
}).bind("keydown.inputmask", keydownEvent
).bind("keypress.inputmask", keypressEvent
).bind("keyup.inputmask", keyupEvent
- ).bind("paste.inputmask", function () {
+ ).bind(pasteEvent + ".inputmask", function () {
var input = this;
setTimeout(function () {
caret(input, checkVal(input, buffer, true));
@@ -1002,4 +1017,4 @@
}
};
}
-})(jQuery);
+})(jQuery);
@@ -3,7 +3,7 @@ Input Mask plugin extensions
http://github.com/RobinHerbots/jquery.inputmask
Copyright (c) 2010 - 2012 Robin Herbots
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 1.0.19a
+Version: 1.0.22
Optional extensions on the jquery.inputmask base
*/
@@ -93,7 +93,8 @@ Optional extensions on the jquery.inputmask base
prevalidator: null
}
},
- insertMode: true
+ insertMode: true,
+ autoUnmask: false
},
'non-negative-decimal': {
regex: {

0 comments on commit 3807453

Please sign in to comment.