Posted By

smonteru on 05/26/11


Tagged

form javascript input jquery


Versions (?)

Form input type text reset onfocus


 / Published in: JavaScript
 

Reset input type text onfocus if value differs from default.

  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $("input[type=text]").focus(function(){
  4. if(this.value == this.defaultValue){
  5. $(this).val("");
  6. }
  7. });
  8. });
  9. </script>

Report this snippet  

You need to login to post a comment.