From 80b2df0617e1afe02d9e183bf603cb7e75b90840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mendel=20Gusm=C3=A3o?= Date: Mon, 21 Nov 2011 17:28:55 -0200 Subject: [PATCH 1/2] Adding support for triggering 'complete' handler when pasting a valid value --- src/jquery.maskedinput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jquery.maskedinput.js b/src/jquery.maskedinput.js index af67604..2793767 100644 --- a/src/jquery.maskedinput.js +++ b/src/jquery.maskedinput.js @@ -248,7 +248,11 @@ .bind("keydown.mask", keydownEvent) .bind("keypress.mask", keypressEvent) .bind(pasteEventName, function() { - setTimeout(function() { input.caret(checkVal(true)); }, 0); + setTimeout(function() { + input.caret(checkVal(true)); + if (checkVal(true) == input.val().length) + settings.completed.call(input); + }, 0); }); checkVal(); //Perform initial check for existing values From c8c640eb6a851edc03393942055ed15434026e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mendel=20Gusm=C3=A3o?= Date: Tue, 22 Nov 2011 11:50:53 -0200 Subject: [PATCH 2/2] Forgot to validate if completed handler exists --- src/jquery.maskedinput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.maskedinput.js b/src/jquery.maskedinput.js index 2793767..7f4d4eb 100644 --- a/src/jquery.maskedinput.js +++ b/src/jquery.maskedinput.js @@ -250,7 +250,7 @@ .bind(pasteEventName, function() { setTimeout(function() { input.caret(checkVal(true)); - if (checkVal(true) == input.val().length) + if (settings.completed && checkVal(true) == input.val().length) settings.completed.call(input); }, 0); });