Form input type text reset onfocus


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

Reset input type text onfocus if value differs from default.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.