Merge pull request #20001 from woocommerce/fix/19996

Check validity before handling submit event in cart
This commit is contained in:
Claudiu Lodromanean 2018-05-08 10:41:16 -07:00 committed by GitHub
commit fb3eacc10f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.
if ( 13 === evt.keyCode ) {
evt.preventDefault();
this.cart_submit( evt );
var $form = $( evt.currentTarget ).parents( 'form' );
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