1/** 2 * Bind validation and AJAX handling for all forms going to a "form_processing" handler 3 * - /forms/form_processing.php 4 * - /forms/form_processing_corporate.php 5 * 6 */ 7$(function() { 8 $('form[action*="form_processing"]').each(function(i) { 9 // get the value from the first (and only) <input name="form_type"> element 10 var formType = $(this).find('input[name=form_type]').first().val(); 11 if (formType != "search" && formType != "corporate") { 12 $(this).validate({ 13 rules: { 14 captchaReqCap: { 15 required: true, 16 remote: { 17 url: "/captcha/captcha_ajax.php", 18 type: "post" 19 } 20 } 21 }, 22 errorPlacement: function(error, element) {}, 23 messages: { 24 captchaReqCap: "Incorrect Code" 25 }, 26 submitHandler: function(form) { 27 $(form).data('validated', true); 28 $.ajax({ 29 url: '/forms/form_processing.php', 30 data: $(form).serialize(), 31 type: 'POST', 32 dataType: 'json', 33 success: function(response) { 34 if(response['success']) { 35 $(form).find("button[type=submit]").first().html("<i class='fa fa-check'></i> Thank You").css({"background-color":"#5cb85c","border-color":"#4cae4c","color":"#fff"}).prop("disabled", true); 36 form.reset(); 37 if (formType == "lead_2") { 38 window.location.href = "/index.php/thank-you"; 39 } 40 } else { 41 $.each(response,function(i, response) { 42 var label = "<label id='" + i + "-error' class='error' for='" + i + "'>" + response + "</label>"; 43 $("[name=" + i + "]").addClass('error'); 44 $("[name=" + i + "]").after(label); 45 }); 46 }; 47 if (typeof grecaptcha != 'undefined') { 48 grecaptcha.reset(); 49 } 50 } 51 }); 52 }, 53 }); 54 i+1; 55 } 56 else if (formType == "corporate") { 57 $(this).validate({ 58 rules: { 59 listId1: { 60 require_from_group: [1, ".listId"] 61 }, 62 listId2: { 63 require_from_group: [1, ".listId"] 64 }, 65 listId3: { 66 require_from_group: [1, ".listId"] 67 }, 68 }, 69 errorPlacement: function(error, element) { 70 if (element.is(':checkbox')) { 71 $(".checkbox_block").addClass('error'); 72 } 73 else { 74 return true; 75 } 76 }, 77 success: function(label){ 78 if ((label.attr('for') == "listId1") || (label.attr('for') == "listId2") || (label.attr('for') == "listId3")) { 79 $(".checkbox_block").removeClass('error'); 80 } 81 }, 82 submitHandler: function(form) { 83 $(form).data('validated', true); 84 $.ajax({ 85 url: '/forms/form_processing_corporate.php', 86 data: $(form).serialize(), 87 type: 'POST', 88 dataType: 'json', 89 success: function(response) { 90 if(response['success']) { 91 $("#buttonsend").html("<i class='fa fa-check'></i> Thank You").css({"background-color":"#5cb85c","border-color":"#4cae4c"}).prop("disabled", true); 92 } 93 else { 94 $.each(response,function(i,response) { 95 var label = "<label id='" + i + "-error' class='error' for='" + i + "'>" + response + "</label>"; 96 $("[name=" + i + "]").addClass('error'); 97 $("[name=" + i + "]").after(label); 98 }); 99 } 100 } 101 }); 102 }, 103 }); 104 i+1; 105 } 106 else { 107 return true; 108 } 109 }); 110 111 //captcha resize functions 112 $(function() { 113 var capWidth = $("#captcha_field").width(); 114 if(capWidth > 300){ 115 $("#captcha").removeClass("captcha-large").removeClass("captcha-medium").removeClass("captcha-small").removeClass("captcha-tiny").addClass("captcha-large") 116 } 117 if(capWidth <= 300){ 118 $("#captcha").removeClass("captcha-large").removeClass("captcha-medium").removeClass("captcha-small").removeClass("captcha-tiny").addClass("captcha-medium") 119 } 120 if(capWidth <= 255){ 121 $("#captcha").removeClass("captcha-large").removeClass("captcha-medium").removeClass("captcha-small").removeClass("captcha-tiny").addClass("captcha-small") 122 } 123 if(capWidth <= 210){ 124 $("#captcha").removeClass("captcha-large").removeClass("captcha-medium").removeClass("captcha-small").removeClass("captcha-tiny").addClass("captcha-tiny") 125 } 126 }); 127});
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.