PageSourceSearch

https://www.wolfram.com/support/contact/js/validation.js

js wolfram.com collected 2026-10-01 06:49:30 UTC 20,983 bytes, 497 lines download raw bytes

1/* Contact-us forms validation
2   @file           forms-ui.en.js
3   @developer      yhechler
4   ========================================================================== */
5$(document).ready(function(){
6var documentSize = function(obj){
7        var fileSize = 0;
8        //for IE
9        if (document.all && document.querySelector && !window.atob) {
10            return true;
11        }
12        //for FF, Safari, Opeara and Others
13        else {
14            fileSize = obj.get(0).files[0].size;     
15
16            //var size = obj.get(0).files[0].size;                                
17            if(fileSize > 15728640){                    
18                // the file is larger than 15MB                    
19                return false;                
20            }else{                    
21                return true;                
22            }  
23        }
24    }
25    var myconf = {
26    'documentExists' :{            
27            selector : $('#documents'),            
28            required : false,            
29        	valid : function(obj){                
30                if(obj.val() == ''){                    
31                    return false;                
32                }else{                    
33                    return true;                
34                }           
35            },
36            scrollTop : function(obj){
37                return obj.parent().offset().top;
38            },           
39           show : function(obj){
40                obj.addClass('error-highlight');                
41                obj.siblings('label').addClass('error');                
42                obj.siblings('.error-msg').show(500);
43            },            
44            hide : function(obj){
45                obj.removeClass('error-highlight');                
46                obj.siblings('label').removeClass('error');                
47                obj.siblings('.error-msg').hide(0);
48            }                   
49        },
50        'documentSize' :{            
51            selector : $('#documents'),            
52            required : function(){
53                return this.v.isTestValid('documentExists');
54            },
55            valid : documentSize,
56            scrollTop : function(obj){
57                return obj.parent().offset().top;
58            },            
59            show : function(obj){
60                obj.addClass('error-highlight');                
61                obj.siblings('label').addClass('error');                
62                obj.siblings('.error-msg').show(500); 
63            },        
64            hide :  function(obj){
65                obj.removeClass('error-highlight');                
66                obj.siblings('label').removeClass('error');                
67                obj.siblings('.error-msg').hide(0);
68            }          
69        },
70     'topic' :{            
71            selector : $('select[name="topic"]'),            
72            required : true,            
73            valid : function(obj){                
74                if(obj.val() == ''){                    
75                    return false;                
76                }else{                    
77                    return true;                
78                }           
79            },
80            scrollTop : function(obj){
81                return obj.parent().offset().top
82            },            
83            show : function(obj){
84                obj.addClass('error-highlight');                
85                obj.siblings('label').addClass('error');                
86                obj.siblings('.error-msg').show(500);
87            },            
88            hide : function(obj){
89                obj.removeClass('error-highlight');                
90                obj.siblings('label').removeClass('error');                
91                obj.siblings('.error-msg').hide(0);
92            }          
93        },
94      'code' :{            
95            selector : $('input[name="code"]'),            
96            required : true,            
97            valid : function(obj){                
98                if(obj.val() == ''){                    
99                    return false;                
100                }else{                    
101                    return true;                
102                }           
103            },
104            scrollTop : function(obj){
105                return obj.parent().offset().top
106            },            
107            show : function(obj){
108                obj.addClass('error-highlight');                
109                obj.siblings('label').addClass('error');                
110                obj.siblings('.error-msg').show(500);
111            },            
112            hide : function(obj){
113                obj.removeClass('error-highlight');                
114                obj.siblings('label').removeClass('error');                
115                obj.siblings('.error-msg').hide(0);
116            }          
117        },
118        'usage' :{            
119            selector : $('select[name="usage"]'),            
120            required : true,            
121            valid : function(obj){                
122                if(obj.val() == ''){                    
123                    return false;                
124                }else{                    
125                    return true;                
126                }           
127            },
128            scrollTop : function(obj){
129                return obj.parent().offset().top
130            },            
131            show : function(obj){
132                obj.addClass('error-highlight');                
133                obj.siblings('label').addClass('error');                
134                obj.siblings('.error-msg').show(500);
135            },            
136            hide : function(obj){
137                obj.removeClass('error-highlight');                
138                obj.siblings('label').removeClass('error');                
139                obj.siblings('.error-msg').hide(0);
140            }          
141        },
142        'description' :{            
143            selector : $('textarea[name="description"]'),            
144            required : true,            
145            valid : function(obj){                
146                if(obj.val() == ''){                    
147                    return false;                
148                }else{                    
149                    return true;                
150                }           
151            },
152            scrollTop : function(obj){
153                return obj.parent().offset().top
154            },            
155            show : function(obj){
156                obj.addClass('error-highlight');                
157                obj.siblings('label').addClass('error');                
158                obj.siblings('.error-msg').show(500);
159            },            
160            hide : function(obj){
161                obj.removeClass('error-highlight');                
162                obj.siblings('label').removeClass('error');                
163                obj.siblings('.error-msg').hide(0);
164            }          
165        },
166        'affiliation_c' :{            
167            selector : $('input[name="affiliation_c"]'),           
168            required : true,            
169            valid : function(obj){    
170                if($('input[name="affiliation_c"]:checked').length == 0){                 
171                    return false;                
172                }else{                    
173                    return true;                
174                }           
175            },
176            scrollTop : function(obj){
177                return $('#is-a-label').offset().top;
178            },            
179            show : function(obj){
180                $('#is-a-label').addClass('error');  
181                $('#radio-buttons').addClass('error');  
182                $('#is-a-error').show(500);                           
183            },            
184            hide : function(obj){
185                $('#is-a-label').removeClass('error');  
186                $('#radio-buttons').removeClass('error'); 
187                $('#is-a-error').hide(0);                         
188            }
189        },
190        
191        'first_name' :{            
192            selector : $('input[name="first_name"]'),           
193            required : true,            
194            valid : function(obj){  
195                if(obj.val() == ''){                    
196                    return false;                
197                }else{                    
198                    return true;                
199                }   
200            },
201            scrollTop : function(obj){
202                return obj.parent().offset().top;
203            },            
204            show : function(obj){
205                obj.addClass('error-highlight');                
206                obj.siblings('label').addClass('error');                
207                obj.siblings('.error-msg').show(500);
208            },            
209            hide : function(obj){
210                obj.removeClass('error-highlight');                
211                obj.siblings('label').removeClass('error');                
212                obj.siblings('.error-msg').hide(0);
213            }          
214        },
215        'last_name' :{            
216            selector : $('input[name="last_name"]'),           
217            required : true,            
218            valid : function(obj){  
219                if(obj.val() == ''){                    
220                    return false;                
221                }else{                    
222                    return true;                
223                }   
224            },
225            scrollTop : function(obj){
226                return obj.parent().offset().top;
227            },            
228            show : function(obj){
229                obj.addClass('error-highlight');                
230                obj.siblings('label').addClass('error');                
231                obj.siblings('.error-msg').show(500);
232            },            
233            hide : function(obj){
234                obj.removeClass('error-highlight');                
235                obj.siblings('label').removeClass('error');                
236                obj.siblings('.error-msg').hide(0);
237            }          
238        },
239         
240        'emailOne' :{            
241            selector : $('input[name="email_address"]'),           
242            required : true,            
243            valid : function(obj){  
244                if(obj.val() == ''){                    
245                    return false;                
246                }else{                    
247                    return true;                
248                }   
249            },
250            scrollTop : function(obj){
251                return obj.parent().offset().top;
252            },            
253            show : function(obj){
254                obj.addClass('error-highlight');                
255                obj.siblings('label').addClass('error');                
256                obj.siblings('.error-msg').eq(0).show(500);
257            },            
258            hide : function(obj){
259                obj.removeClass('error-highlight');                
260                obj.siblings('label').removeClass('error');                
261                obj.siblings('.error-msg').eq(0).hide(0);
262            }          
263        },
264        'emailTwo' :{            
265            selector : $('input[name="email_address"]'),           
266            required : function(){
267                if(this.v.isTestValid('emailOne')){                                       
268                    return true;                
269                }else{                    
270                   return false;
271                } 
272            },            
273            valid : function(obj){  
274                return /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(obj.val()); 
275            },
276            scrollTop : function(obj){
277                return obj.parent().offset().top;
278            },            
279            show : function(obj){
280                obj.addClass('error-highlight');                
281                obj.siblings('label').addClass('error');                
282                obj.siblings('.error-msg').eq(1).show(500);
283            },            
284            hide : function(obj){
285                obj.removeClass('error-highlight');                
286                obj.siblings('label').removeClass('error');                
287                obj.siblings('.error-msg').eq(1).hide(0);
288            }          
289        },
290        'address_country_c' :{            
291            selector : $('select[name="address_country_c"]'),           
292            required : true,            
293            valid : function(obj){  
294                if(obj.val() === ''){                    
295                    return false;                
296                }else{                    
297                    return true;                
298                }  
299            },
300            scrollTop : function(obj){
301                return obj.parent().offset().top;
302            },            
303            show : function(obj){
304                obj.addClass('error-highlight');                
305                obj.siblings('label').addClass('error');                
306                obj.siblings('.error-msg').eq(0).show(500);
307            },            
308            hide : function(obj){
309                obj.removeClass('error-highlight');                
310                obj.siblings('label').removeClass('error');                
311                obj.siblings('.error-msg').eq(0).hide(0);
312            }          
313        },
314        'address_state_c' :{            
315            selector : $('select[name="address_state_c"]'),           
316            required : function(){
317                if($('select[name="address_country_c"]').val() === 'US'){                    
318                    return true;                
319                }else{                    
320                    return false;                
321                } 
322            },          
323            valid : function(obj){  
324                if(obj.val() === ''){                    
325                    return false;                
326                }else{                    
327                    return true;                
328                }   
329            },
330            scrollTop : function(obj){
331                return obj.parent().offset().top;
332            },            
333            show : function(obj){
334                obj.addClass('error-highlight');                
335                obj.siblings('label').addClass('error');                
336                obj.siblings('.error-msg').eq(0).show(500);
337            },            
338            hide : function(obj){
339                obj.removeClass('error-highlight');                
340                obj.siblings('label').removeClass('error');                
341                obj.siblings('.error-msg').eq(0).hide(0);
342            }          
343        },
344        'account_name' :{            
345            selector : $('input[name="account_name"]'),           
346            required : function(){
347                var type = $('input[name="affiliation_c"]:checked').val();
348                if(type == 'Commercial' || type == 'Academic' || type == 'Student' || type=='Government' || type == 'Non-Profit' ){
349                    return true;
350                }else{
351                    return false;
352                }
353            },          
354            valid : function(obj){ 
355                if(obj.val() === ''){                    
356                    return false;                
357                }else{                    
358                    return true;                
359                }   
360            },
361            scrollTop : function(obj){
362                return obj.parent().offset().top;
363            },            
364            show : function(obj){
365                obj.addClass('error-highlight');                
366                obj.siblings('label').addClass('error');                
367                obj.siblings('.error-msg').eq(0).show(500);
368            },            
369            hide : function(obj){
370                obj.removeClass('error-highlight');                
371                obj.siblings('label').removeClass('error');                
372                obj.siblings('.error-msg').eq(0).hide(0);
373            }          
374        },    
375         'department' :{            
376            selector : $('input[name="department"]'),           
377            required : function(){
378                var type = $('input[name="affiliation_c"]:checked').val();
379                if(type == 'Academic' ){
380                    return true;
381                }else{
382                    return false;
383                }
384            },          
385            valid : function(obj){  
386                if(obj.val() === ''){                    
387                    return false;                
388                }else{                    
389                    return true;                
390                }   
391            },
392            scrollTop : function(obj){
393                return obj.parent().offset().top;
394            },            
395            show : function(obj){
396                obj.addClass('error-highlight');                
397                obj.siblings('label').addClass('error');                
398                obj.siblings('.error-msg').eq(0).show(500);
399            },            
400            hide : function(obj){
401                obj.removeClass('error-highlight');                
402                obj.siblings('label').removeClass('error');                
403                obj.siblings('.error-msg').eq(0).hide(0);
404            }          
405        },
406        'title' :{
407            selector : $('input[name="title"]'),           
408            required : function(){
409                var type = $('input[name="affiliation_c"]:checked').val();
410                if(type == 'Commercial' || type=='Government'){
411                    return true;
412                }else{
413                    return false;
414                }
415            },          
416            valid : function(obj){  
417                if(obj.val() === ''){                    
418                    return false;                
419                }else{                    
420                    return true;                
421                }   
422            },
423            scrollTop : function(obj){
424                return obj.parent().offset().top;
425            },            
426            show : function(obj){
427                obj.addClass('error-highlight');                
428                obj.siblings('label').addClass('error');                
429                obj.siblings('.error-msg').eq(0).show(500);
430            
431            },            
432            hide : function(obj){
433                obj.removeClass('error-highlight');                
434                obj.siblings('label').removeClass('error');                
435                obj.siblings('.error-msg').eq(0).hide(0);
436                
437            }          
438        },
439        'consent' :{
440            selector : $('input[name="consent"]'),           
441            required : true,
442            valid : function(){
443                if($('#consent').is(':checked') ){
444                    return true;
445                }else{
446                    return false;
447                }
448            },          
449            scrollTop : function(obj){
450                return obj.parent().offset().top;
451            },            
452            show : function(obj){
453                obj.addClass('error-highlight');                
454                obj.parent('label').addClass('error');                
455                obj.parent('label').next('.error-msg').show(500);
456            },            
457            hide : function(obj){
458                obj.removeClass('error-highlight');                
459                obj.parent('label').removeClass('error');                
460                obj.parent('label').next('.error-msg').hide(0);
461            }         
462        }
463        
464    };
465
466    var myV = $.WriValidator(myconf);    
467    	myV.initialize();
468
469    $('#_form-gui').submit(function(e){
470        if(myV.requiredTestsValid()){
471            $('#_form-gui #submit').prop('disabled', true);
472            $('#_form-gui #submit').toggleClass('thinking');
473            return true;
474        }else{
475            $('#form-error-table').addClass('error');
476            myV.hideAllTestErrors();
477           var top = myV.getRequiredScrollTop();
478
479	     if(typeof(gl_GetHeaderHeight) === "function"){
480	         top = gl_GetHeaderHeight(top);
481            }
482
483            if(top !== false){
484                $('html, body').animate(
485                    {
486                        scrollTop: top 
487                    },
488                    {
489                        complete: function(){myV.showRequiredTestErrors();}
490                    }
491                );
492            }
493            
494            return false;
495        }  
496    });  
497});      

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.