/ Published in: JavaScript
                    
                                        
Remove initial inputfield value on focus.. and place it back on blur in case of empty value.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
$('input:text').focus(function(){
if($(this).val() == $(this).attr('defaultValue')){
$(this).val('');
}
});
$('input:text').blur(function(){
if($(this).val() == ''){
$(this).val($(this).attr('defaultValue'));
}
});
$('textarea').focus(function(){
if($(this).val() == $(this).attr('defaultValue')){
$(this).val('');
}
});
$('textarea').blur(function(){
if($(this).val() == ''){
$(this).val($(this).attr('defaultValue'));
}
});
Comments
 Subscribe to comments
                    Subscribe to comments
                
                