File tree Expand file tree Collapse file tree 1 file changed +10
-16
lines changed
DigitalLearningSolutions.Web/Scripts/frameworks Expand file tree Collapse file tree 1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -72,25 +72,19 @@ if (bfield) wireClearOnInput(bfield);
7272if ( cfield ) wireClearOnInput ( cfield ) ;
7373if ( tfield ) wireClearOnInput ( tfield ) ;
7474
75-
7675form . addEventListener ( "submit" , ( e : Event ) => {
77- const fields = [
76+ [
7877 { el : bfield , msg : "Please enter a valid brand." } ,
7978 { el : cfield , msg : "Please enter a valid category." } ,
8079 { el : tfield , msg : "Please enter a valid topic." }
81- ] ;
82-
83- for ( const f of fields ) {
84- if ( f . el . required ) {
85- if ( ! f . el . value . trim ( ) ) {
86- e . preventDefault ( ) ;
87- f . el . setCustomValidity ( f . msg ) ;
88- f . el . reportValidity ( ) ;
89- f . el . focus ( ) ;
90- return ;
91- } else {
92- f . el . setCustomValidity ( "" ) ;
93- }
80+ ] . forEach ( f => {
81+ if ( f . el . required && ! f . el . value . trim ( ) ) {
82+ e . preventDefault ( ) ;
83+ f . el . setCustomValidity ( f . msg ) ;
84+ f . el . reportValidity ( ) ;
85+ f . el . focus ( ) ;
86+ } else {
87+ f . el . setCustomValidity ( "" ) ;
9488 }
95- }
89+ } ) ;
9690} ) ;
You can’t perform that action at this time.
0 commit comments