Ruby on Rails
HowtoSubmitAjaxFormFromLink

Since form.submit doesn’t trigger the onsubmit callback, which is where all the magic happens, you need something a little more extensive than

link_to_function("Submit", "document.forms['myform'].submit()")

Instead you need something like

link_to_function(name, "if(document.forms['myform'].onsubmit()) { document.forms['myform'].submit(); }")

Or, if you’re planning on using this frequently, you can add the following function to your application_helper.rb file

# Returns a link that'll submit a form, calling its onsubmit handler, 
# using the onclick handler and return false after the fact.
#
# Examples:
#   link_to_formsubmit "Submit", "myform" 
#   link_to_formsubmit(image_tag("submit"), "1")
def link_to_formsubmit(name, id, html_options = {})  
  link_to_function(
    name,
    "if(document.forms['#{id}'].onsubmit()) { document.forms['#{id}'].submit(); }",
    html_options)
end

If your looking at doing something a little different with your forms, this provides you the steps needed and a quick example at using observe_field
HOWTO Show/Hide a Div Using AJAX