Reputation: 931
I have looked on google to find a way to remove text on focus but couldn't figure our how to add it back if nothing was typed in the field.
This is what I have so far...
onfocus="if(this.value == 'Name*') { this.value = ''; }" value="Name*"
This will remove the "Name*" but then it is completely removed for good even if I don't type in the field.
Upvotes: 1
Views: 671
Reputation: 468
Use the onblur event, with a similar if statement saying if it equals nothing then this.value should equal my place holder text.
onblur="if(this.value==''){this.value='Name*';}"
Upvotes: 1
Reputation: 8337
Use JQuery
$("textarea").focus(function() {
if( $(this).val() == "Name*" ) {
$(this).val("");
}
});
Upvotes: 0
Reputation: 7465
This is what you are looking for: http://webdesignerwall.com/tutorials/cross-browser-html5-placeholder-text
Upvotes: 0