Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // Simplest way to do cross-browser input watermarks
  2. // ---------------------------------------------------
  3. // Using 'defaultValue' (as opposed to simple 'value')
  4. // ensures that Firefox doesn't bug out when a user
  5. // types something in, then refreshes the page
  6.  
  7. (function($) {
  8. $.fn.actsAsDefault = function() {
  9. $(this).focus(function() {
  10. if ($(this).val() === this.defaultValue) {
  11. $(this).val('');
  12. }
  13. }).blur(function() {
  14. if ($.trim($(this).val()) === '') {
  15. $(this).val(this.defaultValue);
  16. }
  17. });
  18. };
  19. }(jQuery));
Add Comment
Please, Sign In to add comment