Check validity before handling submit event in cart

This commit is contained in:
Mike Jolley 2018-05-08 12:40:13 +01:00
parent ef15a4c9c3
commit 3d8bb09ee8
2 changed files with 13 additions and 3 deletions

View File

@ -366,8 +366,18 @@ jQuery( function( $ ) {
// Catch the enter key and don't let it submit the form. // Catch the enter key and don't let it submit the form.
if ( 13 === evt.keyCode ) { if ( 13 === evt.keyCode ) {
evt.preventDefault(); var $form = $( evt.currentTarget ).parents( 'form' );
this.cart_submit( evt );
try {
// If there are no validation errors, handle the submit.
if ( $form[0].checkValidity() ) {
evt.preventDefault();
this.cart_submit( evt );
}
} catch( err ) {
evt.preventDefault();
this.cart_submit( evt );
}
} }
}, },

File diff suppressed because one or more lines are too long