File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ function onSubmit ( ) {
2+ var arr = [ ] ;
3+ var extension1 = '.txt' ;
4+ var extension2 = '.pdf' ;
5+ var extension3 = '.docx' ;
6+ var names = this . document . getElementsByClassName ( 'get-attachment ng-binding ng-scope' ) ;
7+ for ( var i = 0 ; i < names . length ; i ++ ) {
8+ var val = names [ i ] . innerHTML ;
9+ arr . push ( val . toString ( ) ) ;
10+ }
11+
12+ var countRequired = 1 ;
13+ if ( window == null ) {
14+ if ( this . document . getElementsByClassName ( 'get-attachment' ) . length != countRequired ) {
15+ g_form . addErrorMessage ( 'You can add only one attachment' ) ;
16+ return false ;
17+ }
18+ }
19+
20+ for ( var j = 0 ; j < arr . length ; j ++ ) {
21+ if ( ( arr [ j ] . indexOf ( extension1 ) > - 1 ) || ( arr [ j ] . indexOf ( extension2 ) > - 1 ) || ( arr [ j ] . indexOf ( extension3 ) > - 1 ) ) {
22+ return true ;
23+ } else {
24+ g_form . addErrorMessage ( 'Unsupported file format. Please attach files with extensions .txt, .pdf, .doc' ) ;
25+ return false ;
26+ }
27+
28+ }
29+
30+ }
You can’t perform that action at this time.
0 commit comments