clearing search/text boxes - javascript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. add the following code in the <HEAD> </HEAD> part of your document:
  2.  
  3. <script type="text/javascript">
  4. <!--
  5. function clearDefault(el) {
  6. if (el.defaultValue==el.value) el.value = ""
  7. }
  8. // -->
  9. </script>
  10.  
  11.  
  12. Then use this script in your search/text box:
  13.  
  14. <FORM>
  15. Email: <INPUT TYPE=text VALUE="E-Mail Address" ONFOCUS="clearDefault(this)"><BR>
  16. Search: <INPUT TYPE=text VALUE="Search Text" ONFOCUS="clearDefault(this)">
  17. </FORM>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.