form_for with :onsubmit

hello list

I have a problem with form_for and :onsubmit

this is may code

<div id="note"> <% javascript_tag do %> function valor(){ alert('aqui'); } <% end %>

<% form_for :accion, :url=>{:controller=> "accions", :action=> "anadir"}, :html=>{:onsubmit=>"valor();"} do |f| %>

..... <%= f.submit "Go" %> <%end %>

</div>

when I click in buttom nothing happen with javascript function valor(), I don´t see the alert

this is my html code <div id="note"> <form onsubmit="valor();" method="post" action="/accions/anadir"> <div style="margin: 0pt; padding: 0pt;"> </div> <table width="700" border="1"> </table> </form> </div>

but i don´t find the javascript code of javascript_tag

any idea???

thanks for all