Adding javascript to f.text_field

In a current project of mine I have a div field that is located behind
a text_field that is acting like a row in a table. Whenever someone
hovers over the whitespace in the row the background color changes.
However, when they click the text area in the row the highlight
disappears. I would like the highlight to remain when the text_box is
the focus. I know how to write the javascript for this, but I don’t
know where to put it in the code.

Code:

<%= f.text_field :email, :size => 30 %>

Thanks

you can pass other html attributes similar to :size, e.g.

<%= f.text_field :email, :size => 30, :onchange => ‘…’, :onfocus=>
‘…’ %>

etc.

personally, I like to use lowpro

http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype

which lets me extact scripting to a .js file and clean up my views