Clear text_area value onfocus

Hi!

I have a "text_area" that looks like this...

<%= text_area 'business', 'otherDigitalDesc', "cols" => 25, "rows" => 4, "value" => "Enter Description if Yes..." %>

Right now, if I submit it, it adds "Enter Description if Yes" into the database. It would be nice to not have it enter this, but if a user clicks on the box, it clears this out. I'm thinking of using onfocus, but my only fear is that if somebody clicks off and then back onto the box, won't it clear their description? Is there a better/easier way to do this?

Thanks, mike

Hey!

How about this:

"onfocus" => "this.value=''; this.onfocus=null;"

I can't claim credit for this; I stole it from: Clearing <textarea> upon first click - JavaScript and AJAX forum at WebmasterWorld - WebmasterWorld

Hope it helps though!

- Louis.

I would like to do the same thing. It would be nice to not have to have a label for the text field in some circumstances. I've seen this done really well but I can't find a way to do it properly in rails. I don't know what to even search for. Any ideas?

Hi!

Thanks for the information. This actually works really well....but now I have a second/original problem.

How do I make it so that "Enter Description if Yes" does not get entered into the database, while a real answer does? For example, if nobody clicks on the textboxes, it will enter "Enter Description if Yes" into the db. Is there something in the model or controller I can say "if value = "Enter Description if Yes" { don't put in } else { put in db}"?

Thanks! Mike