Formatted Input Masks for Textboxes

08Nov06

One fancy way to provide a bit of extra usability sugar on a form is to have formatting automatically applied to a textfield as the user types. I’ve been using a fantastic Mask Formatter javascript library created by PengoWorks for some time now on a number of production sites. This javascript can be configured different ways to constrain the user’s input to only certain characters, validate date format, etc. Check out the documentation on the PengoWorks site for ways it can be configured.

I’m uploading a slightly tweaked copy here since the version on that site hasn’t seen any changes in quite a while. I’ve made some minor bug fixes to it, but unfortunately I didn’t document exactly what I’ve changed. Primarily, I’ve focused on cleaning up the date format implementation.

  1. First, view the examples at Pengoworks.
  2. then download my modified js source file.

One day I’d like to rewrite the logic here and make use of all of the enhancements in the prototype.js library. This one’s nice though, in that it doesn’t have any dependancies.

It goes without saying that this should not be used as a replacement for server-side validation of user input; it’s simple to bypass javascript validation of this sort by disabling javascript in your browser.

Flash 6 Actionscript Version:

I also wrote an implementation of textbox input masks for Flash 6. I haven’t tested or worked with this in newer versions of Flash, so I don’t know if it is still applicable. It was basically an actionscript 1.0 port/rewrite of the input mask class in the Java Swing framework. Hopefully this can be a starting point for using in your own Flash-based application:

Preview Flash 6 Input Mask | Download Actionscript Source

1 Response to “Formatted Input Masks for Textboxes”


  1. 1 Brad Grant Posted February 17th, 2007 - 1:12 pm Quote

    Nice job. This works great for date input especially. Thank you for sharing.

Leave a Reply


Comment guidelines: No spamming, no profanity, and no flaming. Inappropriate comments will be deleted outright.

Quote selected text




 

About

My name is Dylan Marks. I'm a programmer and tech consultant focused on web application development, typically using ASP.NET, javascript and web standards-based technologies. I hope to share some of the useful tips and tricks I've discovered while making things work. I live in Edmonton, Alberta, Canada, working remotely for clients across North America. Email Me.