jQuery Prepopulated form fields


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



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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.