I don't know if this is even possible, but in my rails app, I have this currently to put text in a text_field to be a description instead of having an external label:
<% inside = "Search for Customers" %>
<%= text_field_tag :search, params[:search],
:style => "color:#aaa;",
:value => inside, #defined above
:onfocus => "if(this.getValue()=='#{inside}'){this.clear();this.style.color = '#000';}",
:onblur => "if(this.getValue()==''){this.setValue('#{inside}');this.style.color = '#aaa';}" %>
<%= submit_tag "Search", :name => nil %>
This works great, but if I don't enter anything in, it searches for "Search for Customers", which is not what I intended. Is there a way to fix this?
Thanks
Edit:
I've added a :onSubmit => "if(this.getValue()=='#{inside}'){this.clear();}"
to the text_field_tag, but it's still not doing anything. I've also tried :onbeforesubmit
and even a simple alert('test')
but it's not working for some reason.