prashantcs053
7/3/2017 - 11:42 AM

custom address field for gravity form for on keyup to hidden field

custom address field for gravity form for on keyup to hidden field

//type 1
    function nike_form_address($this) {
        var output = [];
        $this.find("input[type='text']").each(function() {
            if (jQuery(this).val().trim() != "") {
                output.push(jQuery(this).val());
            }
        });
        return output.length > 0 ? output.join('|') : '';
    }

//type 2
    function nike_form_address($this) {
        var address = $this.find(".address_line_1").find("input[type='text']").val();
        var city = $this.find(".address_city").find("input[type='text']").val();
        var state = $this.find(".address_state").find("input[type='text']").val();
        var zip = $this.find(".address_zip").find("input[type='text']").val();
        var output = address + "|" + city + "|" + state + "|" + zip;
        return output;
    }
    
 jQuery("#cus_address_1, #cus_address_3, #cus_address_4, #cus_address_5").keyup(function () {
            var $this = jQuery(this);
            var output = nike_form_address($this.parents(".cus_address"));
            $this.parents("tr").children('td').eq(2).children("input[name='input_12\[\]']").val(output);
        });