I have an input box that has default value text assigned to it. How can I remove this text when the user focuses on the field::
CoDE
<input type="text" name="kp1_description" value="Enter Keypress Description">
I have an input box that has default value text assigned to it. How can I remove this text when the user focuses on the field::
CoDE
<input type="text" name="kp1_description" value="Enter Keypress Description">
With HTML5 you could do it without Javascript: just use
placeholder
instead ofvalue
. I think it's a nice addition, but of course you need to check the browser compatibility first.HTML:
Javascript code:
That's all, I hope it'll help.
Plain JavaScript:
This keeps the value in the placeholder instead of removing it completely. If you do not like this, remove the placeholder line.