• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Bye, Bye Helper Text

Sometimes it is necessary to have a form field already filled out so that users understand what they are supposed to enter. The only problem with this method is that it means the users have to delete the prefilled 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: onfocus="this.value=''". 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:

onfocus="if(this.value==this.defaultValue)this.value=''"


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint