@@ -47,14 +47,11 @@ class Pattern extends BasePattern {
4747 this . form ,
4848 "submit" ,
4949 `pat-validation--submit--validator` ,
50- ( e ) => {
50+ ( event ) => {
5151 // On submit, check all.
5252 // Immediate, non-debounced check with submit. Otherwise submit
5353 // is not cancelable.
54- for ( const input of this . inputs ) {
55- logger . debug ( "Checking input for submit" , input , e ) ;
56- this . check_input ( { input : input , event : e } ) ;
57- }
54+ this . validate_all ( event ) ;
5855 } ,
5956 // Make sure this event handler is run early, in the capturing
6057 // phase in order to be able to cancel later non-capturing submit
@@ -72,6 +69,13 @@ class Pattern extends BasePattern {
7269 this . form . setAttribute ( "novalidate" , "" ) ;
7370 }
7471
72+ validate_all ( event ) {
73+ // Check all inputs.
74+ for ( const input of this . inputs ) {
75+ this . check_input ( { input : input , event : event , stop : true } ) ;
76+ }
77+ }
78+
7579 initialize_inputs ( ) {
7680 this . inputs = [
7781 ...this . form . querySelectorAll ( "input[name], select[name], textarea[name]" ) ,
@@ -426,10 +430,7 @@ class Pattern extends BasePattern {
426430 // and after the submit button is disabled there is no way for the user
427431 // to check the whole form at once.
428432 if ( did_disable ) {
429- logger . debug ( "Checking whole form after element was disabled." ) ;
430- for ( const _input of this . inputs . filter ( ( it ) => it !== input ) ) {
431- this . check_input ( { input : _input , stop : true } ) ;
432- }
433+ this . validate_all ( ) ;
433434 }
434435 }
435436
0 commit comments