Is there any way to set focus in a particular field, after validation in
(assume there is no username given)
after validation, how can i set focus in that particular username
ya i can do it with JS,
any way in rails??
you. I've put together a little example: http://pastie.org/405697 Call
the method somewhere in your view and the method _should_ make some
Keep in mind that it's untested so if it doesn't work you might need
to fix an error or two, or maybe ask for help here.
I've revised the example a bit. This works perfectly for me. Feel free
to try it out: http://pastie.org/405733
I need to mention that in the latest example (http://pastie.org/
405733) I'm also overriding the #error_messages_for method, so now you
can actully focus on the first field that has errors automatically.
The only thing you need to change is your application layout. Put:
<%= yield :head %>
... just before </head>. And then of course add the two methods to
your application helper file. Hope it helps...