Form Field: How do I change the background on blur?

Posted by Liso22 on Stack Overflow See other posts from Stack Overflow or by Liso22
Published on 2011-01-09T19:38:45Z Indexed on 2011/01/09 19:53 UTC
Read the original article Hit count: 220

Filed under:
|
|

I managed to remove the background when the user clicks on the field but I cannot restore it when it blurs!

This is the field:

       <textarea class="question-box" style="width: 240px; background: 
    white url('http://chusmix.com/Imagenes/contawidget.png') no-repeat 
    50% 50%; color: grey;" cols="12" rows="5"  id="question-box-' . 
    $questionformid . '" name="title" onblur="if(this.value == '') { 
    this.style.color='#848484'; this.value=''this.style.background='
white url('http://chusmix.com/Imagenes/contawidget.png') no-repeat 50% 50%;e';}" 
    onfocus="if (this.value == '') {this.style.color='#444'; 
    this.style.background='none';}" type="text" maxlength="200" size="28"></textarea>

Anyone knows what I'm doing wrong?? Thanks

© Stack Overflow or respective owner

Related posts about css

Related posts about forms