Browse Source

onBeforePaste callback - #399 monoblaine

Robin Herbots 12 years ago
parent
commit
3d267cff60

+ 16 - 0
README.md

@@ -457,6 +457,22 @@ This can be usefull when implementing an alias, ex. decimal alias, autofill the
 
 see jquery.inputmask.extensions.js for some examples
 
+### onBeforePaste
+
+This callback allows for preprocessing the pasted value before actually handling the value for masking.  This can be usefull for stripping away some characters before processing.
+
+```javascript
+$(document).ready(function(){
+   $("#test").inputmask("99.", {
+                repeat: 4,
+                onBeforePaste: function (pastedValue) {
+                    //do somehing with the value
+                    return pastedValue;
+                }
+            });
+});
+```
+
 ### hasMaskedValue
 
 Check whether the returned value is masked or not; currently only works reliably when using jquery.val fn to retrieve the value 

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 2
 build.minor = 4
-build.revision = 12
+build.revision = 13
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

+ 1 - 1
component.json

@@ -1,6 +1,6 @@
 {
     "name": "jquery.inputmask",
-    "version": "2.4.12",
+    "version": "2.4.13",
     "main": "./dist/jquery.inputmask.bundle.js",
     "dependencies": {
         "jquery": ">=1.7"

BIN
dist/jQuery.InputMask.2.4.12.nupkg


BIN
dist/jQuery.InputMask.2.4.13.nupkg


File diff suppressed because it is too large
+ 1379 - 1444
dist/jquery.inputmask.bundle.js


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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

File diff suppressed because it is too large
+ 1371 - 1436
js/jquery.inputmask.js


+ 1 - 1
qunit/qunit.html

@@ -11,7 +11,7 @@
   <!-- <script src="http://code.jquery.com/jquery-1.6.min.js"></script> -->
   <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
   <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
-  <script src="../dist/jquery.inputmask.bundle.min.js"></script>
+  <script src="../dist/jquery.inputmask.bundle.js"></script>
   <script src="./tests.js"></script>
 </body>
 </html>

+ 19 - 0
qunit/tests.js

@@ -497,6 +497,25 @@ asyncTest("inputmask(\"+7 (999) 999-99-99\") ~ paste \"+7 (+79114041112___) ___-
 
 });
 
+asyncTest("inputmask(\"+7 (999) 999-99-99\") ~ paste \"0079114041112\" - monoblaine", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("+7 (999) 999-99-99", {
+		onBeforePaste : function(pastedValue) {
+			//just simplistic for the test ;-)
+			var strippedValue = pastedValue.substr(2);
+			return strippedValue;
+		}
+	});
+    $("#testmask").paste("0079114041112");
+    
+    setTimeout(function () {
+	equal($("#testmask").val(), "+7 (911) 404-11-12", "Result " + $("#testmask").val());
+	start();
+	$("#testmask").remove();
+    }, 0);
+
+});
+
 module("Set value with fn.val");
 test("inputmask(\"decimal\") ~ value=\"123.45\"", function () {
     $('body').append('<input type="text" id="testmask" />');