Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear a text box

Status
Not open for further replies.

LLudlow

Programmer
Oct 5, 2001
186
CA
I have a text box on my form to submit an email address. After the address has been submitted the text stays in the text box. How can i clear it?
 
Hi lludlow,

To clear the textbox, just set it's value to "", you can apply this on the onsubmit event handle, so it will clear the field when you submitting the form.

example:

<html>
<head>
<script>
function clearTextField() {
document.myform.email.value = &quot;&quot;;
}
</script>
</head>
<body>

<form name=&quot;myform&quot;
action=&quot;sendmail.pl&quot;
method=&quot;post&quot;
onsubmit=&quot;clearTextField()&quot;>
<input type=&quot;text&quot; name=&quot;email&quot; value=&quot;&quot;>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
</form>

</body>
</html>

hope this helps, Chiu Chan
WebMaster & Software Engineer
emagine solutions, inc
cchan@emagine-solutions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top