Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe Dreamweaver

BYE, BYE HELPER TEXT

Sometimes it is necessary to have a form field already filled out so users understand what they are supposed to enter. The only problem with this method is that it means the users have to delete the pre-filled entry themselves, which can be annoying—especially if there are many fields to clear. You can make it easier by clearing the text for them with some easy JavaScript. To clear an <input> tag's value, add the following:

You wouldn't want to clear the form every time the user clicks inside it because that could really get annoying. Let's clear the field only if the default value specified by the value attribute of the <input> tag is present, by using this code instead:

A great way to add this code is by first clicking on the field in Design view to select it, and then adding the value to the onFocus attribute in the Tag inspector.

Figure7.18Figure 7.18

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus