JQuery blur function not working second time -


hi have textbox has "enter ur name" @ loading. when focus on it, become empty , if dont type , blur change again "enter ur name". works fine many times. problem if focus , enter , removed characters, textbox empty. logic if textbox empty should have "enter " name. jquery here code. pls suggest something.

  $(document).ready(function (){     var name='enter name';     $('input[type="text"]').attr('value',name).focus(function(){             if($(this).val() == name){                 $(this).attr('value','');             }     }).blur(function(){             if($(this).val() == ''){                 $(this).attr('value',name);             }     })   }); 

try this. works fine.....

$(document).ready(function(){     var msg= 'enter email.....';     $('input[type="email"]').attr('value',msg).focus(function(){             if($(this).val()==msg){                     $(this).val('');              }      }).blur(function(){              if($(this).val()==''){             //alert($(this).val());                     $(this).val(msg);              }       });   }); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -