home | software | javascripts | textboxes with hints
Sometimes the best way to hint what must be entered into a textbox is to put some text in the textbox. Using this javascript makes the process straightforward. Its key features are:
Add this to the <head> section of your HTML document:
class attribute on your input element to be hintTextbox. For example:
Here are a collection of textboxes. Experiment with clicking in, tabbing between and setting then deleting values.
This script may not behave as expected when forms are pre-populated with values that are not hints,
perhaps by a server-side script. In such cases, the server's value would be treated as a hint
(i.e. appearing grey and disappearing when focussed). Do not set the class name to hintTextbox
for such fields.
hint-textbox.js - right-click and choose save as