Reputation: 127
This might be some stupidity from my part but I cant figure this out. Pls see the 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;
return confirm("An email will be sent to "+email+" on behalf of your request. Proceed?");
}
</script>
The form submits even when I click cancel. What am I doing wrong here? Thanks in advance.
Upvotes: 0
Views: 89
Reputation: 1447
try instead of
onclick:"submit_form();"
this:
onclick: "return submit_form();"
Upvotes: 2