Browse Source

added hasMaskedValue fn

Robin Herbots 13 years ago
parent
commit
353ae9a5e1
3 changed files with 21 additions and 3 deletions
  1. 15 0
      README.md
  2. 3 1
      js/jquery.inputmask.js
  3. 3 2
      js/jquery.inputmask.numeric.extensions.js

+ 15 - 0
README.md

@@ -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
 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
 ## Supported markup options
 ### RTL attribute
 ### RTL attribute

+ 3 - 1
js/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2012 Robin Herbots
 * Copyright (c) 2010 - 2012 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: 1.0.21
+* Version: 1.0.22
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -137,6 +137,8 @@
                         if (this.data('inputmask'))
                         if (this.data('inputmask'))
                             return this.data('inputmask')['_buffer'].join('');
                             return this.data('inputmask')['_buffer'].join('');
                         else return "";
                         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:
                     default:
                         //check if the fn is an alias
                         //check if the fn is an alias
                         if (!resolveAlias(fn)) {
                         if (!resolveAlias(fn)) {

+ 3 - 2
js/jquery.inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Copyright (c) 2010 - 2012 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: 1.0.19a
+Version: 1.0.22
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -93,7 +93,8 @@ Optional extensions on the jquery.inputmask base
                     prevalidator: null
                     prevalidator: null
                 }
                 }
             },
             },
-            insertMode: true
+            insertMode: true,
+            autoUnmask: false
         },
         },
         'non-negative-decimal': {
         'non-negative-decimal': {
             regex: {
             regex: {