Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. // placeholder on
  2. jQuery(function() {
  3. jQuery.support.placeholder = false;
  4. webkit_type = document.createElement('input');
  5. if('placeholder' in webkit_type) jQuery.support.placeholder = true;});
  6. $(function() {
  7. if(!$.support.placeholder) {
  8. var active = document.activeElement;
  9. $(':text, textarea, :password').focus(function () {
  10. if (($(this).attr('placeholder')) && ($(this).attr('placeholder').length > 0) && ($(this).attr('placeholder') != '') && $(this).val() == $(this).attr('placeholder')) {
  11. $(this).val('').removeClass('hasPlaceholder');
  12. }
  13. }).blur(function () {
  14. if (($(this).attr('placeholder')) && ($(this).attr('placeholder').length > 0) && ($(this).attr('placeholder') != '') && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
  15. $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
  16. }
  17. });
  18. $(':text, textarea, :password').blur();
  19. $(active).focus();
  20. $('form').submit(function () {
  21. $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
  22. });
  23. }
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement