1function validation(form) { 2 var valid = true; 3 4 remove_error(); 5 6 form.find('.required').each(function(e){ 7 let $this = jQuery(this), 8 type = $this.attr('type'), 9 label = typeof($this.attr('aria-label')) == "undefined" ? 'This' : $this.attr('aria-label'); 10 email_feedback = '<span class="invalid-feedback">Please input a valid email address.</span>'; 11 12 if( $this.val() == '') { 13 valid = false; 14 feedback = '<span class="invalid-feedback">' + label + ' is required.</span>'; 15 16 if( type == "checkbox" ) { 17 $this.addClass('is-invalid').parent().parent().parent().append(feedback); 18 } else { 19 $this.addClass('is-invalid').after(feedback); 20 } 21 } else if( $this.val() !== '' && type == "email" ) { 22 let isEmailValid = check_email($this.val()); 23 24 if ( !isEmailValid ) { 25 valid = false; 26 $this.addClass('is-invalid').after(email_feedback); 27 } else { 28 jQuery(this).removeClass('is-invalid'); 29 } 30 } else { 31 jQuery(this).removeClass('is-invalid'); 32 } 33 }); 34 35 if( !valid ) { 36 form.prepend('<div class="form-message form-not-valid">Please fill out all required fields and try again.</div>'); 37 } 38 return valid; 39} 40 41function check_email(email) { 42 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 43 return regex.test(email); 44} 45 46function remove_error() { 47 jQuery('.invalid-feedback, .form-not-valid').remove(); 48} 49 50// function ajax(action, method, data, form) { 51// return jQuery.ajax({ 52// type: method.toUpperCase(), 53// url: action, 54// data: data, 55// beforeSend: function(){ 56// form.find('.required').addClass('form-sending'); 57// form.append('<div class="preloader"></div>'); 58// }, 59// }).fail(function(response, textStatus, jqxHR) { 60// alert('Server Error!'); 61// console.log(response, textStatus, jqxHR); 62// }); 63// } 64 65// function onSubmit(token) { 66// document.getElementById("g-recaptcha-response").value = token; 67// // console.log(token, 'success!'); 68// }
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.