JS validation on a form/submit tag? Like :condition=>

Hallo – is there a way anyone know of that I can add a :confirm clause
to a form submit? Something like:
<%= submit_tag ‘commit’, :confirm=>“are you certain?” %>
Does anyone know how to achieve this?
Cheers,
doug.

My guess is that would need to go in the onclick handler for the form.

-Jonny.

From the top of my head I remember this.

However, check it in different browsers first!

Hi – the way I did it was like this:
I created a helper method in ‘application_helper.rb’:

def confirm_submit_tag(value=“submit”, msg=“Are you sure?”)
“<input type=“submit” value=”#{value}" onclick=“return
confirm(’#{msg}’);” />"
end

& then, in the rhtml (inside the form), I can just use

<%= confirm_submit_tag ‘commit’, “This will commit the changes you
made.” %>

It works well in firefox & IE.
Cheers for the input!
doug.