AAA
AAA

Reputation: 3168

Textarea on focus

I am using the code below to try and get the value to show before clicking. I want the value "reply here" to show in the texarea and when someone clicks it should go away letting them type their reponse. I am using the code below but it doesn't show the value until one click in the box. How can i tweak it?

    onclick="this.value='';" onfocus="this.select()" 
    onblur="this.value=!this.value?'Reply          
    here':this.value;" value="Reply here"

Upvotes: 0

Views: 347

Answers (2)

wulymammoth
wulymammoth

Reputation: 9061

I'm searching for a different answer, but thought I could shine some light on what's available with HTML5. All you need to do is do the following:

<textarea placeholder="Reply here"></textarea>

However, I'm sure it doesn't work with much older browsers, but here's a link to get backward compatibility: how to use HTML5 placeholder attribute with backward-compatibility in mind?

Upvotes: 0

Danny Hiemstra
Danny Hiemstra

Reputation: 1188

textarea's dont take the "value" attribute, to set a default value of a textarea use the following:

<textarea>reply here</textarea>

Upvotes: 1

Related Questions