From 957ff8dac8ebaf8a0d97a5bf1aa03e4b0fc387ac Mon Sep 17 00:00:00 2001 From: Nathan Long Date: Wed, 7 Sep 2011 16:53:21 -0400 Subject: [PATCH 1/2] Added 'unmasked' event --- README.md | 8 +++++++- src/jquery.maskedinput.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64828ed..dc46992 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,10 @@ This is a masked input plugin for the jQuery javascript library. It allows a use * a - Represents an alpha character (A-Z,a-z) * 9 - Represents a numeric character (0-9) -* \* - Represents an alphanumeric character (A-Z,a-z,0-9) \ No newline at end of file +* \* - Represents an alphanumeric character (A-Z,a-z,0-9) + +Events +-------- + +- `unmasked.maskedInput` is triggered when the input is blurred and the mask is cleared. If you're performing separate validation, it may be useful to bind validation to this event. For example, if you're checking whether a field is empty, you don't want to consider the temporary placeholders in a field. When this event is triggered, they will be gone. + diff --git a/src/jquery.maskedinput.js b/src/jquery.maskedinput.js index af67604..db49e16 100644 --- a/src/jquery.maskedinput.js +++ b/src/jquery.maskedinput.js @@ -244,6 +244,7 @@ checkVal(); if (input.val() != focusText) input.change(); + input.trigger('unmasked.maskedInput'); }) .bind("keydown.mask", keydownEvent) .bind("keypress.mask", keypressEvent) From 3a7a4960df0d67a4cf25aae0af2040e3f45307d0 Mon Sep 17 00:00:00 2001 From: Nathan Long Date: Thu, 17 May 2012 09:27:48 -0400 Subject: [PATCH 2/2] Multi-line `if` needs curly braces --- src/jquery.maskedinput.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jquery.maskedinput.js b/src/jquery.maskedinput.js index db49e16..f95c0b1 100644 --- a/src/jquery.maskedinput.js +++ b/src/jquery.maskedinput.js @@ -242,9 +242,10 @@ }) .bind("blur.mask", function() { checkVal(); - if (input.val() != focusText) + if (input.val() != focusText) { input.change(); input.trigger('unmasked.maskedInput'); + } }) .bind("keydown.mask", keydownEvent) .bind("keypress.mask", keypressEvent)