Posted By

thegrevster on 06/02/11


Tagged

form input jquery prepopulated


Versions (?)

jQuery Prepopulated form fields


 / Published in: jQuery
 

  1. var improve = $('.improve'),
  2. $input = improve.find('input'),
  3. specify = "Please specify";
  4.  
  5. $input
  6. .val(specify)
  7. .bind('focus', function() {
  8. if ($(this).val()===specify){
  9. $(this).val('');
  10. }
  11. })
  12. .bind('blur', function() {
  13. if (!$.trim($(this).val())) {
  14. $(this).val(specify);
  15. }
  16. });

Report this snippet  

You need to login to post a comment.