views:

1096

answers:

1

I'm trying to change the value on a <textarea> element. This code works great in Firefox, but IE claims there's an error onblur and doesn't set the value.

<textarea 
    name="comment" 
    id="comment" 
    rows="8" 
    cols="80"
    style="color:grey;" 
    onfocus="if(this.value=='Add a comment...') {this.style.color='black'; this.value='';}"
    onblur="if(this.value=='') {this.style.color='grey'; this.value='Add a comment...';}">Add a comment...</textarea>

What am I doing wrong?

+2  A: 

Can this be causing the problem -

this.style.color='grey'

?

this.style.color='gray';

Whole Code:

<textarea name="comment" id="comment" rows="8" cols="80" style="color: gray;" onfocus="if(this.value=='Add a comment...') {this.style.color='black'; this.value='';}"
        onblur="if(this.value=='') {this.style.color='gray'; this.value='Add a comment...';}">Add a comment...</textarea>
Kirtan
Most likely, they are American Colour names ;)
Chad Grant
Yep - Its American COLOR names :)
Kirtan