|
Polishing the Mask
You have now successfully created a masked textbox by taking into account all the textbox's behaviors and creating a control that's safe to use in Web applicationsand that works with all major browsers. You can extend this technique to restrict textbox entry for e-mail addresses, zip codes, phone numbers
almost anything you could possibly need while developing Web applications.
The code in the final example is by no means meant to be the final code that you use to mask textboxes. For example, here are some suggestions for polishing the code:
- Create a single JavaScript function that will mask a given textbox in one step, instead of having to independently assign the onkeypress, onchange, and onpaste event handlers.
- Make the mask into an HTML behavior (for use in IE only).
- Create a generic way to apply masking based on the naming convention for textboxes. This avoids the need to assign all functions on every textbox.
- Modify the functions in this article to be able to handle masking of multiple textboxes on the same HTML page.
 |
Nicholas C. Zakas is a User Interface Designer for Web applications at MatrixOne, Inc. Nicholas works primarily as a client-side developer using JavaScript, DHTML, XML and XSLT. He can be reached via e-mail at
nicholas@nczonline.net.
|
|
|
 |
TALK
BACK |
|
Creating a masked edit text box in DTHML is not as straightforward as it seems at first. Do you know of other masked edit examples? Join the discussions at web.dhtml.scripting to get answers, make comments, or help others with their problems.
|
|
|
|
|
|
|