File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -677,20 +677,23 @@ var jsRuleSets = {
677677 } ,
678678 file : function ( elem ) {
679679 var list_to_allow = elem . target . getAttribute ( 'data-extensions' ) ;
680+ var target = elem . target ;
680681 var list_to_allow_array ;
681- var inputID = elem . target . getAttribute ( 'id' ) ;
682682 var file_response ;
683683 if ( '' === list_to_allow ) return true ;
684- if ( - 1 === list_to_allow . indexOf ( ',' ) ) list_to_allow = [ list_to_allow ] ;
685-
686- list_to_allow_array = list_to_allow . split ( ',' ) ;
687-
688- var fileName = document . getElementById ( inputID ) . value ;
684+ // Slit into array of extensions.
685+ if ( - 1 === list_to_allow . indexOf ( ',' ) ) {
686+ list_to_allow_array = [ list_to_allow ] ;
687+ } else {
688+ list_to_allow_array = list_to_allow . split ( ',' ) ;
689+ }
690+ // Get file name.
691+ var fileName = target . value ;
689692 // Convert to lower case for native validation.
690693 fileName = fileName . toLowerCase ( ) ;
691694 file_response = ( new RegExp ( '(' + list_to_allow_array . join ( '|' ) . replace ( / \. / g, '\\.' ) + ')$' ) ) . test ( fileName ) ;
692695 if ( false === file_response ) {
693- alert ( 'Allowed file types are ' + list_to_allow + ' !' ) ;
696+ alert ( 'Allowed file types are " ' + list_to_allow + '" !' ) ;
694697 // Reset file type.
695698 elem . target . value = '' ;
696699 return false ;
You can’t perform that action at this time.
0 commit comments