开发者

textarea placeholder message

Just doing a text area, and for inputs we can use placeholder text:

name="inputname" value="Enter Text Here" onfocus="if(this.value == 'Enter Text Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Text Here'; }"

But in textarea it doesnt work, until you click in the field and back out again.

Any fix for this please ?

TO ADD

We are pulling saved entry from form, and spewing it out between the tag elements like:

......><?=str_replace("<br开发者_运维知识库 />", "", $somestuff);?></textarea>


Default text for textarea goes in between the tags, not in the value attribute, like this:

<textarea name="inputname" onfocus="if(this.value == 'Enter Text Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Text Here'; }">Enter Text Here</textarea>


You can still use value, but now the text is within the textarea element.

<textarea 
name="inputname" value="Enter Text Here" onfocus="if(this.value == 'Enter Text Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Text Here'; }" >Enter Text Here</textarea>


http://www.jsfiddle.net/KG5UE/4/

Your code works just fine for me in Chrome. Here's a jsfiddle to prove it.

Oh, for textarea? Sorry, my fingers are faster than my eyes....

Go for what Dustin said, he's right .... Updated jsfiddle to include both cases


I tried the following file on IE7 and it worked.

<html>

<body>

<textarea name="inputname" value="Enter Text Here" onfocus="if(this.value == 'Enter Text Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Text Here'; }" ></textarea>

</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜