
Originally Posted by
geoffb
Im in the proccess of building a form for a site, and would like to know how to make the initial valus dissapear when a user goes to submit text into each box.
One can alter the value of a control when it receives focus, but it's not usually a good idea. Playing with input like that can just confuse the visitor - not everyone may understand why a value just disappeared.
Many of you may wonder why i'm not using <label for=""> to place outside the text areas, and although I have used these on previous sites im after something different on this one.
Before you continue, ask yourself: if the value that presumably indicates the purpose of that control is gone, will the visitor still understand, upon reviewing the form, what each of the given responses where meant to represent? If it is not abundantly clear, I would urge you not to pursue this.
Code:
function clearDefault(control) {
if (control.value == control.defaultValue) control.value = '';
}
HTML Code:
<input type="text" value="..." onfocus="clearDefault(this);">
You may need to be careful here to ensure that the visitor would not want to use the default value as their response.
Mike
Bookmarks