javascript - form submits even when I click cancel in confirm form submission dialog -



javascript - form submits even when I click cancel in confirm form submission dialog -

this might stupidity part cant figure out. pls see code below.

<%= submit_tag "send request", :class=>"btn btn-primary", onclick:"submit_form();"%> <script type="text/javascript"> function submit_form(){ var email = document.getelementbyid('customer_email').value; homecoming confirm("an email sent "+email+" on behalf of request. proceed?"); } </script>

the form submits when click cancel. doing wrong here? in advance.

try instead of

onclick:"submit_form();"

this:

onclick: "return submit_form();"

javascript ruby-on-rails

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -