1function initValidateFields() { 2 var formNames = $('input[name="form"]'); 3 if (formNames.length) { 4 $.each(formNames, function (i, formName) { 5 $.post("/ws/form-check-validation/", { formName: formName.value }, function (validateOnInput) { 6 if (validateOnInput) { 7 8 var $form = $(formName.closest('form')); 9 if (!$form.length) return false; 10 11 $form.on('focusout validate', ':input', function (e) { 12 // Slight delay to prevent blinking for longer running actions 13 // i.e google autocomplete field 14 15 var $inputField = $(this); 16 setTimeout(function () { 17 if ($inputField.attr('type') === 'file' && e.type === "focusout") return false; 18 19 var formData = new FormData(); 20 $.each($form.serializeArray(), function (i, v) { 21 formData.append(v.name, v.value); 22 }); 23 if ($form.find("input[type='file']").length) { 24 var fileUpload = $form.find("input[type='file']"); 25 $.each($(fileUpload)[0].files, function (i, file) { 26 formData.append($(fileUpload)[0].name, file); 27 }); 28 29 var filename = $.map($(fileUpload)[0].files, function (file, i) { 30 return file.name; 31 }).join(","); 32 33 formData.append("filename", filename); 34 } 35 if ($(".form-selected-service:checked").length) { 36 var services = []; 37 $.each($(".form-selected-service:checked"), function (i, file) { 38 services.push($(this).val()); 39 }); 40 formData.append("service", services); 41 } 42 formData.append("fieldName", $inputField.attr('name')); 43 formData.append("formName", formName.value); 44 45 $.ajax({ 46 type: "POST", 47 cache: false, 48 dataType: "json", 49 url: "/ws/form-validate-field/", 50 data: formData, 51 processData: false, 52 contentType: false, 53 success: function (valid) { 54 fieldInvalid($inputField, valid); 55 } 56 }); 57 }, 450); 58 }); 59 } 60 }); 61 }); 62 } 63} 64 65function fieldInvalid($inputField, valid) { 66 var $parent = $inputField.closest(".form-group"); 67 if (!valid && !$parent.hasClass("has-error")) { 68 $parent.addClass("has-error has-feedback"); 69 $inputField.after("<span class='far fa-exclamation-circle form-control-feedback' aria-hidden='true'></span>"); 70 } else if (valid) { 71 $parent.removeClass("has-error has-feedback"); 72 $parent.find(".form-control-feedback").remove(); 73 } 74} 75 76initValidateFields();
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.