gravity form list field validation all repeater added
jQuery(document).on("submit", "#gform_2", function (e, v) {
var tableRow = jQuery(".gfield_list_group");
if (jQuery(".gfield_list_group:visible").length > 0) {
tableRow.removeClass("map_add_error");
var k = 0;
tableRow.each(function () {
var errorby_fields = false;
var time = jQuery(this).attr("unique-id");
var manualAdd = nike_form_address(jQuery(this));
var manualAdd_arr = manualAdd.split("|");
var map_add = jQuery(this).find("input[name='input_12\[\]']").eq(0).val();
var $status = false;
if (map_add.trim() != "") {
$status = true;
} else if ((manualAdd_arr[0].trim() != "") && (manualAdd_arr[1].trim() != "") && (manualAdd_arr[2].trim() != "")) {
$status = true;
}
if ($status == false) {
jQuery(".gfield_list_group[unique-id=" + time + "]").addClass("map_add_error");
jQuery(this).find(".gfield_list_12_cell1 label").not("#cus_address_5_label").css({"color": "#ca0606", "font-weight": "700"});
jQuery(this).find(".gfield_list_12_cell1 input[type='text']").not("#cus_address_5").css({'border': '2px solid #ca0606'});
jQuery(this).find('.addr_empty').remove();
jQuery(this).find(".gfield_list_12_cell1 input[type='text']").not("#cus_address_5").after("<div class='addr_empty gfield_description validation_message'>This field is required.</div>");
jQuery(this).find(".gfield_description.validation_message").eq(k).css({"color": "#ca0606", "font-family": "'Lato', serif", "font-size": "14px", "line-height": "18px", "font-weight": "400", "padding-right": "0", "padding-top": "0", "bottom": "-20px"});
if (manualAdd_arr[0].trim() != "") {
jQuery(this).find("#cus_address_1").trigger("change");
}
if (manualAdd_arr[1].trim() != "") {
jQuery(this).find("#cus_address_3").trigger("change");
}
if (manualAdd_arr[2].trim() != "") {
jQuery(this).find("#cus_address_4").trigger("change");
}
}
k++;
});
if (jQuery(".map_add_error").length > 0) {
e.preventDefault();
var scrollt = jQuery(".map_add_error").offset().top;
scrollt = scrollt - 150;
jQuery("body").animate({
scrollTop: scrollt
}, 1500, function () {
});
window["gf_submitting_2"] = false;
jQuery('.gform_wrapper .gform_ajax_spinner').remove();
return false;
}
}
});