I have an unusual problem with a form (here’s a slimmed down version):
<script>
(function($){
$("form").submit(function(){
alert('Checkout time!');
});
$("button[name='process_order']").click(function(){
alert('Button Checkout time!');
});
$("button[name='back']").click(function(){
alert('Back Button');
});
})(jQuery);
</script>
<form>
<input type="text" name="moo1" tabindex="1" />
<input type="text" name="moo2" tabindex="2" />
<button name="back" tabindex="4">Back</button>
<button name="process_order" tabindex="3">Process Order</button>
</form>
The buttons work fine, however, if I hit enter when one of the textboxes that has focus, the ‘Back Button’ action is what fires… even though the form’s submit handler is set to do “checkout”…
You could probably change the process_order tothis:
<input type="submit" name="process_order" value="Process Order" tabindex="3" />And change to:
<form id="myForm">Then, bind the .submit() handler to it