HTML Forms


I have a form with two buttons - [1] Create [2] Cancel. By default if a user clicks on any of them, the form gets submitted. However, I dont want to do that. I want to call a javascript function on cancel and form submit (as usual) on create. How can this be achieved?

Well where do you want the cancel button to go ? reset the form and back to the new task? or some other page?

Just use a link_to or button_to for the cancel button... Don't make it part of the form...

So why is 'Cancel' a submit button? Make it a reset button and attach your handler to it.