Posted By

must on 08/25/10


Tagged

input jquery mask


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

must
dubogii


Input Mask


 / Published in: jQuery
 

  1. (function($) {
  2. $.fn.mask = function() {
  3. return $(this).each(function() {
  4. var
  5. $this = $(this),
  6. text = $this.val();
  7.  
  8. //when focused ont the input
  9. $this.focus(function(){
  10. if($this.val() == text)
  11. $this.val("");
  12. });
  13. //looses focus
  14. $this.blur(function() {
  15. if($this.val() == "")
  16. $this.val(text);
  17. });
  18. });
  19. }
  20. })(jQuery);
  21.  
  22. $(document).ready(function() {
  23. $('#input').mask();
  24. });

Report this snippet  

You need to login to post a comment.