1function set_checkbox_requirements() { 2 var answers_num = $('.required_answers',$(this).closest('fieldset')).val(); 3 var checked_num = $(':checked',$(this).closest('fieldset')).length; 4 5 if(typeof answers_num != "undefined") { //only check for required answers if required answers exist 6 if(checked_num >= answers_num) { 7 //$('span:first-child .form-checkbox',$(this).closest('fieldset')).get(0).setCustomValidity(''); 8 //$('span:first-child .form-checkbox',$(this).closest('fieldset')).removeAttr('required'); 9 //console.log($('.form-checkbox',$(this).closest('fieldset'))); 10 var temp = $('.form-checkbox',$(this).closest('fieldset')); 11 $('input.form-checkbox',$(this).closest('fieldset')).each(function(){$(this).removeAttr('required');}); 12 $('input.form-checkbox',$(this).closest('fieldset')).each(function(){$(this)[0].setCustomValidity('');}); 13 } else { 14 if(typeof answers_num != "undefined" && answers_num > 0) { 15 optiontext = 'option'; 16 if(answers_num > 1) optiontext = 'options'; 17 //$(this).get(0).setCustomValidity('You must select at least ' + answers_num + ' ' + optiontext); 18 $('input.form-checkbox',$(this).closest('fieldset')).each(function(){ 19 $(this)[0].setCustomValidity('You must select at least ' + answers_num + ' ' + optiontext); 20 }); 21 } 22 //console.log($('.form-checkbox',$(this).closest('fieldset'))); 23 var temp = $('.form-checkbox',$(this).closest('fieldset')); 24 $('input.form-checkbox',$(this).closest('fieldset')).each(function(){$(this).attr('required',true);}); 25 26 } 27 } 28} 29 30$(document).ready(function() { 31 $('.responsive-form').each(function() { 32 var myForm = $(this); 33 $('fieldset .form-checkbox',myForm).each(function() { 34 var answers_num = $('.required_answers',$(this).closest('fieldset')).val(); 35 if(typeof answers_num != "undefined" && answers_num > 0) { 36 optiontext = 'option'; 37 if(answers_num > 1) optiontext = 'options'; 38 $(this)[0].setCustomValidity('You must select at least ' + answers_num + ' ' + optiontext); 39 } 40 }); 41 }); 42 $('.responsive-form .form-checkbox').on('change', set_checkbox_requirements); 43 $('.responsive-form .form-checkbox').each(set_checkbox_requirements); 44}); 45 46//returns true if the email is valid and false if it is not 47function validate_email(email) { 48 const mailExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 49 return mailExp.test(email); 50} 51 52//returns an array containing any invalid emails from the list; array will be length zero if all are valid 53function validate_email_list(email_list) { 54 var invalid_emails = []; 55 56 comma = email_list.indexOf(","); 57 semicolon = email_list.indexOf(";"); 58 59 if (comma >= 0 && semicolon >= 0) { 60 //they used both commas and semicolons 61 var email_array = []; 62 var temp_array = email_list.split(","); 63 for (let i = 0; i < temp_array.length; i++) { 64 var cur_array = temp_array[i].split(';'); 65 email_array.concat(cur_array); 66 } 67 } else if (comma >= 0) { 68 var email_array = email_list.split(","); 69 } else if (semicolon >= 0) { 70 var email_array = email_list.split(";"); 71 } else { 72 //just a single entry 73 var email_array = []; 74 email_array.push(email_list); 75 } 76 77 for (let i = 0; i < email_array.length; i++) { 78 var cur_email = email_array[i].trim() 79 result = validate_email(cur_email); 80 if (!result) { 81 invalid_emails.push(cur_email); 82 } 83 } 84 return invalid_emails; 85}
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.