$(document).ready(function() {
																
													formEl = $('#kt_form');
													var btn = formEl.find('[data-ktwizard-type="action-submit"]');

													var initValidation = function() {
		validator = formEl.validate({
			// Validate only visible fields
			ignore: ":hidden",

			// Validation rules
			rules: {
				//= Step 1
				customerName: {
					required: true
				}
				
				
			},
			

			// Display error
			invalidHandler: function(event, validator) {
				KTUtil.scrollTop();

				swal.fire({
					"title": "",
					"text": "Alcuni dati sono errati o mancanti, correggili prima di proseguire",
					"type": "error",
					"confirmButtonClass": "btn btn-secondary"
				});
			},

			// Submit valid form
			submitHandler: function (form) {

			}
		});


	}

	initValidation();

		btn.on('click', function(e) {
			e.preventDefault();
			sendForm()
		})

	

													var sendForm = function(){
	
	var btn = formEl.find('[data-ktwizard-type="action-submit"]');

	if (validator.form()) {
				// See: src\js\framework\base\app.js
				KTApp.progress(btn);
				//KTApp.block(formEl);

				// See: http://malsup.com/jquery/form/#ajaxSubmit
				formEl.ajaxSubmit({
					success: function() {
						KTApp.unprogress(btn);
						//KTApp.unblock(formEl);

						swal.fire({
							"title": "",
							"text": "Cliente modificato con successo!",
							"type": "success",
							"confirmButtonClass": "btn btn-secondary"
						}).then(function(result) {
							console.log("Redirect alla lista");
							document.location.href = window.location.href.split('?')[0] + "?p=17";
							
                if (result.value) {

                }
            })


					}
				});
			
}
}
})