This repository was archived by the owner on Dec 11, 2017. It is now read-only.
Apply/Remove the mask when re-masking a field#44
Closed
galaban wants to merge 1 commit intodigitalBush:masterfrom
Closed
Apply/Remove the mask when re-masking a field#44galaban wants to merge 1 commit intodigitalBush:masterfrom
galaban wants to merge 1 commit intodigitalBush:masterfrom
Conversation
Owner
|
I'm not sure what is wrong with the behavior as it is. http://jsfiddle.net/GMvHg/ It seems to work as you describe it should. |
Author
|
That's odd! It seems to work well on jsfiddle, but not on my box. (Yeah, I know that doesn't help much, does it?) In fact, it's not behaving at all like what I'm seeing. I'm not sure if this is due to other code we have in place, other code jsfiddle has in place, or possibly differences in framework. But I know that this change fixed the problem we were having and it seems to work nicely with the code. I thought I'd just share this with you in case you wanted to add it. I noticed someone else had a similar problem with initializing the buffer[]. (Issue #35, #35) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are two problems that I solved with this fix.
By initializing the buffer[] to the focus text, I was able to send data to the control and have it be correctly populated. So, if I clicked on the textbox and immediately hit Escape, the data would stay there.
When attempting to re-mask the field, I got some wild results. Going from a mask of "999-99-99" to "9999999" caused the mask to be nine characters long, adding the placeholder where the original dashes were and causing the input to go into the places where the original mask specified. (Ugh. Just not good.)
To recreate:
Begin with a mask:
input.mask('999-99-99', {placeholder:'0'});
Then change the mask dynamically:
input.mask('9999999', {placeholder:'0'});
The fix was to remove the mask when we did the UnMask, storing the original data (NOT the masked data but the actual values entered) into the original text box.
I have only tested this on IE8, so you should probably double check it.