var form1 = $(".tab-wizard").serialize();
$(".tab-wizard").steps({
    headerTag: "h6"
    , bodyTag: "section"
    , transitionEffect: "slide"
    , titleTemplate: '<span class="step">#index#</span> #title#'
    , labels: {
        finish: "Salvar"
    }

    , onFinished: function (event, currentIndex) {
        swal("Form 1 Submitted!", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem erat eleifend ex semper, lobortis purus sed.");

    }

    , onStepChanging: function (event, currentIndex, newIndex, form) {

        if (!$("#jobTitle1").val()) {
            salvar();
        }
        return currentIndex > newIndex || !(3 === newIndex
            && Number($("#age-2").val()) < 18)
            && (currentIndex < newIndex )
        // && (form.find(".body:eq(" + newIndex + ") label.error").remove(), form.find(".body:eq(" + newIndex + ") .error").removeClass("error")), form.validate().settings.ignore = ":disabled,:hidden", form.valid())
    }
});

function salvar() {
    var formData = new FormData();
    formData.append('imagemNotificacao', $("#firstName1").val());
    formData.append('idHospedagem', $("#lastName1").val());

    $.ajax({
        type: "POST",
        url: "http://[::1]/lider/pecas/testeadd",
        data: formData,
        dataType: 'json',
        contentType: false,
        cache: false,
        processData: false,
        success: function (data) {

            $("#jobTitle1").val(data.resposta)

        }
    });


}

var form = $(".validation-wizard").show();


$(".validation-wizard").steps({
    headerTag: "h6"
    , bodyTag: "section"
    , transitionEffect: "fade"
    , titleTemplate: '<span class="step">#index#</span> #title#'
    , labels: {
        finish: "Salvar"
    }
    , onStepChanging: function (event, currentIndex, newIndex) {
        return currentIndex > newIndex || !(3 === newIndex &&
            Number($("#age-2").val()) < 18) &&
            (currentIndex < newIndex &&
            (form.find(".body:eq(" + newIndex + ") " +
                "label.error").remove(),
                form.find(".body:eq(" + newIndex + ") .error").removeClass("error")),
                form.validate().settings.ignore = ":disabled,:hidden",
                form.valid())
    }
    , onFinishing: function (event, currentIndex) {
        return form.validate().settings.ignore = ":disabled", form.valid()
    }
    , onFinished: function (event, currentIndex) {
        swal("Form 2 Submitted!", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem erat eleifend ex semper, lobortis purus sed.");
    }

}), $(".validation-wizard").validate({
    ignore: "input[type=hidden]"
    , errorClass: "text-danger"
    , successClass: "text-success"
    , highlight: function (element, errorClass) {
        $(element).removeClass(errorClass)
    }
    , unhighlight: function (element, errorClass) {
        $(element).removeClass(errorClass)
    }
    , errorPlacement: function (error, element) {
        error.insertAfter(element)
    }
    , rules: {
        email: {
            email: !0
        }
    }
})