Masked Input Plugin 1.3

There is now a new version of my Masked Input Plugin for jQuery.  This is primarily a bugfix release. The biggest deal for me with this release has been the addition of a test suite.  In order to do so, I ended up writing a keystroke simulator which I call keymasher. It's not a perfect way to test, but it's better than nothing.

As a product of adding the tests, I found a few inconsistent issues with the delete and backspace handling which are now resolved. I was also able to take advantage of some event normalization that jQuery provides which didn't exist when I first wrote this plugin.  That plus a switch to UglifyJS has resulted in a smaller compressed file size (3.26KB for v1.3 vs 3.46KB for v1.2.2).

Bugfixes:

  • Fixed completed callback bug.
  • Fixed IE bug requiring charAt() instead of array notation to access char within string.
  • Fixed delete key handling with cursor at literal character.
  • Fixed infinite focus loop bug with multiple masked inputs on a page.
  • Fixed raw value returning mask placeholders when input empty.

Enhancements:

  • Now gracefully handle it when mask() gets called multiple times by calling unmask() on behalf of the user.

As always, if you have encounter any issues, please feel free to report them over on my github project. I'll do my best to  fix them in a timely manner. Also, if this plugin has helped you out, feel free to throw a few bucks my way by clicking the donate button at the top of the page.

State of the Masked Input Plugin

This post should be titled, "Dude, Where the Hell have You Been?" I'm sorry I have ignored this project for so long.

New Home
First, let me get started by saying that I moved the source to github a while back.  It now lives here. If you look at the commit history, I moved it there months ago, fixed a few outstanding bugs, added a feature that someone needed for a specific project and then just left it. I'm picking it back up somewhat, but we'll talk about that in a minute.

Email Bankruptcy
There have been a TON of emails from you guys; so many that I haven't been able to keep up.  Most of the emails have been about two bugs: an off by one goof I made for the completed function and forgetting to use charAt() to access a char in a string. These bugs are fixed in the github repo right now (I think). I'm calling my email situation a total loss.  Sorry to those that have emailed me and not gotten a response.

Birth of a New Project
Part of the reason I stalled on this project was a lack of tests.  For a while I wasn't sure how to even test this thing given that it is purely driven from user input.  Up to this point I had just been opening up a test page in every browser I could think of and running through a few things manually.  A couple of weeks ago I sat down one night and spiked out a rough version of a keystroke simulator which I'm now calling KeyMasher. Please be kind, it's still very rough. Once I get it more polished, I'll put up an official project page on my blog here.  I had found a few other projects which do this and jquery.autotype seemed to be the closest fit. Unfortunately I couldn't get it to work with my specific needs, so I've now written my own with a syntax I feel more comfortable with.  I've already worked out a few tests using this against my masked input plugin.

I'm Just One Guy
After I get a half way acceptable set of tests around it, then I can feel a bit more confident about what I change.  I would like to be able to implement some of the features I've seen come across my email. It will take some time to get everything to a place where it should have already been.  Please be patient, I'll get there. :)

Masked Input Plugin 1.2.2

There is now a new version of my Masked Input Plugin for jQuery.  This is primarily a bugfix release which addresses some edge cases.  Additionaly, I made a few changes that I feel make the plugin behave more natural so that the user experience isn't affected too much by using the plugin.
A few other things worth noting:  This is my first build for this plugin that uses a build script.  No longer am I compressing the javascript by hand.  I'm hoping to extend the script further so that future releases are easier.  Also, I'm now compressing the script with YUI Compressor.
This release has been tested with jQuery 1.3.2 and 1.2.6.
Bugfixes
  • Fixed bug which blocked apple meta key.  This was keeping copy and paste via keyboard shortcut from working on Mac.
  • Fixed bug that caused mask literals to be pushed into the mask placeholder positions when verifying the data.
  • Fixed bug that prevented user input from completing when mask ended in mask literal.

Changes

  • Changed behavior on focus to select all text if focusing on a completed mask.
  • No more masking on readonly inputs.
  • Changed escape behavior to put the input back to the original value instead of just blanking the text.
  • Increased range of accepted characters for input.

Masked Input Plugin 1.2.1

There is now a new version of my Masked Input Plugin for jQuery.  Version 1.2.1 moves one step closer to my bigger picture for the plugin.  I had to make a few breaking changes to do so, but I feel that the end result is worth it.  This release adds a lot more polish to the 1.2 release.  Here's what we've got.

  • BREAKING CHANGE: Removed deprecated $.mask.addPlaceholder method.  Use the "$.mask.definitions['']="";" syntax instead.  I said I was going to do this on the last release and now seems just as good a time as any.
  • BREAKING CHANGE: Removed "allowPartial" option in favor of new mask syntax I'll describe below.  A discussion and code exchange with Michael Bray inspired this change.  I hate that it's a breaking change, but the new way makes a lot more sense.
  • New mask syntax option '?'.  Anything listed after '?' within the mask is considered optional user input.  The common example for this is phone number + optional extension.  The new syntax will look like this: "(999) 999-9999? x99999"
  • I got rid of the awkward input behavior where users typed over top of existing input.  The plugin acted like a word processor Insert mode.  This has always agrivated me, so now the input shifts on input and backspace/delete.
  • Now calling .change() on blur if the value has changed since the plugin prevents the change event from being fired naturally.
  • Pasting incomplete test no longer wipes the input.  Instead, the cursor is just placed where the input leaves off.
  • Fixed backspace detection for iPhone.  Plugin is now iPhone compatible.
  • Fixed pasting bug when mask starts with a literal and caret position is on the literal character.
I feel really good about this release.  I made some changes that I feel are good for the direction of the plugin.  Iif you don't like some of the changes please let me know and I'll look at adding them back in as options.  I'm trying hard not to bloat things up, but I don't want to remove features that are needed.

Masked Input Plugin 1.2

There is now a new version of my Masked Input Plugin for jQuery. After a long absence with this project, I finally decided to tackle some of the more requested features that have been sent to me. I also did some big reorganization to make room for some future enhancements. With all the changes, it seemed appropriate to bump this version from the 1.1 series.

  • Paste support for more browsers. It should now work in IE7, Firefox 3, Safari, Chrome, and Opera.
  • Fixed backspace bug in Opera.  I had originally put in special handling for Opera to get past a bug that appears to be fixed in current releases.  This code is now removed.
  • Calling .mask() with no arguments will now return the value of the input without the literals.
  • Added option "allowPartial" that will allow partial input to remain when focus is lost.
  • Exposed the hash table of the mask definitions directly to replace the $.mask.addPlaceholder() method.  The old method remains for now, but will be removed in a future relase.  You should now add custom mask definitions by "$.mask.definitions[char]=regex;"
  • Code refactoring and  house cleaning.  I made things more jQuery like and removed some crufty code in the process.  The end result is better organization to build on for future enhancements.

Next Page »