function closePopForm(e){ e.preventDefault(); $(".modal-plan--form, .modal-background-plan--form").fadeOut(); } $.getScript("//resources.libertycr.com/js/jquery.validate.min.js", function () { $.extend($.validator.messages, { required: "Este campo es obligatorio.", number: "Este campo debe ser de tipo numérico", email: "Este campo debe ser de tipo email", minlength: "8 caracteres mínimo", }); $.validator.addMethod("notEqual", function(value, element, param) { return this.optional(element) || value != param; }, "Por favor, selecciona un valor."); $("form#form--andrey").validate({ errorClass: "outline--error", validClass: "outline--success", rules: { "name_form": { "required": true }, "contrato_form": { "required": true, "number":true }, "comment_form": { "required": true }, "tel_form":{ "required":true, "number":true }, "ruta_form": { "required": true, "notEqual":"default" }, "terminos_form": { "required":true } }, }); }); $("form#form--andrey a.btn-liberty").click(function(e){ e.preventDefault(); if ($("#form--andrey").valid()) { var name_form = $("#name_form").val(); var contrato_form = $("#contrato_form").val(); var comment_form = $("#comment_form").val(); var ruta_form = $("#ruta_form option:selected").val(); var terminos_form = $("#terminos_form").val(); var tel_form = $("#tel_form").val(); $(".modal-background-plan--form").fadeIn(); $(".loading--modal").fadeIn(); indigitall.setExternalCode(tel_form , function(device) { console.log("INDIGITALL: Phone updated"); },(error) => { console.log("INDIGITALL: Phone not updated"); }); setTimeout(() => { $.post("//apis.libertycr.com/api/mvcr1403/store", { name: name_form, num_contract: contrato_form, comment:comment_form, contact_phone:tel_form, route:ruta_form }).done(function (data) { $(".loading--modal").fadeOut(); if (data.result == true) { $("div#success-modal").fadeIn(); } else { $("div#error-modal").fadeIn(); } }); $(".loading--modal").fadeOut(); }, 2000); } })