@@ -47,14 +47,11 @@ class Pattern extends BasePattern {
47
47
this . form ,
48
48
"submit" ,
49
49
`pat-validation--submit--validator` ,
50
- ( e ) => {
50
+ ( event ) => {
51
51
// On submit, check all.
52
52
// Immediate, non-debounced check with submit. Otherwise submit
53
53
// 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 ) ;
58
55
} ,
59
56
// Make sure this event handler is run early, in the capturing
60
57
// phase in order to be able to cancel later non-capturing submit
@@ -72,6 +69,13 @@ class Pattern extends BasePattern {
72
69
this . form . setAttribute ( "novalidate" , "" ) ;
73
70
}
74
71
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
+
75
79
initialize_inputs ( ) {
76
80
this . inputs = [
77
81
...this . form . querySelectorAll ( "input[name], select[name], textarea[name]" ) ,
@@ -426,10 +430,7 @@ class Pattern extends BasePattern {
426
430
// and after the submit button is disabled there is no way for the user
427
431
// to check the whole form at once.
428
432
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 ( ) ;
433
434
}
434
435
}
435
436
0 commit comments