From 46382d46e96826f5b507bd8a492ae04664ee9aa5 Mon Sep 17 00:00:00 2001 From: Arseny Zarechnev Date: Tue, 12 Mar 2013 18:54:12 +0400 Subject: [PATCH] fix issues with all change events --- jquery.maskMoney.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/jquery.maskMoney.js b/jquery.maskMoney.js index 835a1d2..f3d06ce 100644 --- a/jquery.maskMoney.js +++ b/jquery.maskMoney.js @@ -65,12 +65,6 @@ markAsDirty(); input.val(input.val().replace('-','')); return false; - } else if (k == 13 || k == 9) { // enter key or tab key - if(dirty){ - clearDirt(); - $(this).change(); - } - return true; } else if ($.browser.mozilla && (k == 37 || k == 39) && e.charCode == 0) { // needed for left arrow key or right arrow key with firefox // the charCode part is to avoid allowing '%'(e.charCode 0, e.keyCode 37) @@ -120,12 +114,6 @@ maskAndPosition(x, startPos); markAsDirty(); return false; - } else if (k==9) { // tab key - if(dirty) { - $(this).change(); - clearDirt(); - } - return true; } else if ( k==46 || k==63272 ) { // delete key (with special case for safari) preventDefault(e); if(x.selectionStart == x.selectionEnd){ @@ -157,6 +145,7 @@ textRange.collapse(false); // set the cursor at the end of the input textRange.select(); } + this.initialValue = input.val() } function blurEvent(e) { @@ -179,6 +168,12 @@ input.val(setSymbol(getDefaultMask())); } } + + if(dirty && this.initialValue !== input.val()) { + $(this).change(); + clearDirt(); + } + } function preventDefault(e) {