/ Published in: JavaScript
Expand |
Embed | Plain Text
<html><head><title>(Type a title for your page here)</title> <script type="text/javascript"> function make_blank() { document.form1.type.value =""; } </script> </head> <body > <form name=form1 method=post action='test.php'> <b>Type</b><input type=text name=type value='Enter your user id' onclick="make_blank();">Enter User ID <input type=submit value=Submit> </form> </body> </html>
Comments
Subscribe to comments
You need to login to post a comment.

This will remove whatever is in the text box every time the user clicks on it?
Yes.
Here is a better way, no function needed:
... onclick="this.value='';">Enter User ID...
I modded the script a bit for my search box... Here it is:
function make_blank() { if(document.form1.q.value!="DEFAULT VALUE HERE") { } else { document.form1.q.value =""; } }
onClick="if(this.value=='name')this.value=' ';"
i have put a space between single quotes to show its not double quotes
the reverse of this on focus out if you want to be more interactive