# Form\_for with :onsubmit

**URL:** <https://www.ruby-forum.com/t/form-for-with-onsubmit/159017>\
**Category:** Rails\
**Created:** [January 30, 2009, 1:19pm UTC](https://www.ruby-forum.com/t/form-for-with-onsubmit/159017 "2009-01-30T13:19:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@maite](https://www.ruby-forum.com/u/maite)\
**Post date:** [January 30, 2009, 1:19pm UTC](https://www.ruby-forum.com/t/form-for-with-onsubmit/159017/1 "2009-01-30T13:19:15Z")

</div>

hello list

I have a problem with form\_for and :onsubmit

this is may code

\<% 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 %\>

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

this is my html code

but i donÂ´t find the javascript code of javascript\_tag

any idea???

thanks for all
