Merge pull request #20001 from woocommerce/fix/19996
Check validity before handling submit event in cart
This commit is contained in:
commit
fb3eacc10f
|
@ -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
Loading…
Reference in New Issue