Tarjeta de Registro en Línea

'); } else if (action == "redirectUrl") { window.location = result.data.redirectUrl; } else if (action == "showThankYou") { var thankYouHtml = form.find(".mf-thankyou").html(); thankYouHtml = form.find(".mf-thankyou").html().replace(/\{([^{}]*)(\|){1}([A-Za-z0-9_]+)\}/g, function(key) { var text = key.replace(/[{}]+/g, ""); var inputId = text.split("|")[1]; return $("#" + inputId).length > 0 ? $("#" + inputId).val() : ""; }); form.find(".mf-thankyou").html(thankYouHtml); showPage(form.find(".mf-pages>.mf-page").length - 1); form.find(".mf-progress-bar-animated").removeClass("mf-progress-bar-animated"); $('html,body').animate({ scrollTop: form.offset().top - 40 }, 500, 'linear'); } } else { // Validation not passed if (result.data && result.data.type == "validation") { if (result.data.errors) { $.each(result.data.errors, function(k, v) { var input = $("#" + k); if (input.length == 0) { input = $("input[name='" + k + "']"); } if (input.is(":visible")) { var val = String(input.val()).trim(); if (input.attr("type") == "radio" || input.attr("type") == "checkbox") { val = input.filter(":checked").val(); val = typeof val == "undefined" ? "" : val; } var errorMessages = []; if (v) errorMessages.push(v); if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();} } }); } } else if (result.data && result.data.type == "fileuploads") { var input = $("#" + result.data.id); var errorMessages = []; if (result.data.error) errorMessages.push(result.data.error); if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();} } } }, error: function(error) { form.removeClass("mf-form-loading"); if (error.responseJSON) { alert(error.responseJSON.data); } else { alert("Check your internet connection!"); } } }); } }); /** * Next button click on multi page forms */ form.find(".mf-next-btn").on("click", function() { var isFormValid = true; var currentPage = parseFloat(form.find(".mf-page:visible").attr("data-index")); // var id = "#magicform-1"; $('html,body').animate({ scrollTop: form.offset().top - 40 }, 500, 'linear'); if(currentPage==0){var errorMessages = [];var input = $("#datePicker_1_4");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#datePicker_1_5");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#text_1_9");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#text_1_10");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#address_1_27");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#address_1_27_address1");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#address_1_27_city");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#address_1_27_country");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#address_1_27_state");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#phone_1_32");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#phone_1_32");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();var pattern = new RegExp(/^([0-9]{9}|[0-9]{10})+$/i);if (val != "" && !pattern.test(val)) {var errorMessage = buildErrorMessage("Ingrese unicamnete 9 ó 10 dígitos | Must have 9 or 10 digits",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#email_1_33");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("#email_1_33");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();var pattern = new RegExp(/^(([^()\[\]\.,;:\s@"]+(\.[^()\[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i);if (val != "" && !pattern.test(String(val).toLowerCase())) {var errorMessage = buildErrorMessage("Ingrese un correo válido | Please enter a valid email",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}var errorMessages = [];var input = $("input[name='radioButton_1_23_value']");var val = input.filter(':checked').val();val = typeof val == "undefined" ? "" : val;if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}}if(currentPage==1){var errorMessages = [];var input = $("input[name='termsOfUse_1_34']");var val = input.filter(':checked').val();val = typeof val == "undefined" ? "" : val;if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}} if (isFormValid) { showPage(currentPage + 1); } }); /** * Previous button click on multi page forms */ form.find(".mf-back-btn").on("click", function() { var currentPage = parseFloat($("#magicform-1 .mf-page:visible").attr("data-index")); showPage(currentPage - 1, "back"); }); $("#datePicker_1_4").on("blur change", function() {var errorMessages = [];var input = $("#datePicker_1_4");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#datePicker_1_5").on("blur change", function() {var errorMessages = [];var input = $("#datePicker_1_5");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#text_1_9").on("blur change", function() {var errorMessages = [];var input = $("#text_1_9");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#text_1_10").on("blur change", function() {var errorMessages = [];var input = $("#text_1_10");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#address_1_27").on("blur change", function() {var errorMessages = [];var input = $("#address_1_27");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#address_1_27_address1").on("blur change", function() {var errorMessages = [];var input = $("#address_1_27_address1");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#address_1_27_city").on("blur change", function() {var errorMessages = [];var input = $("#address_1_27_city");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#address_1_27_country").on("blur change", function() {var errorMessages = [];var input = $("#address_1_27_country");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#address_1_27_state").on("blur change", function() {var errorMessages = [];var input = $("#address_1_27_state");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#phone_1_32").on("blur change", function() {var errorMessages = [];var input = $("#phone_1_32");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#phone_1_32").on("blur change", function() {var errorMessages = [];var input = $("#phone_1_32");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();var pattern = new RegExp(/^([0-9]{9}|[0-9]{10})+$/i);if (val != "" && !pattern.test(val)) {var errorMessage = buildErrorMessage("Ingrese unicamnete 9 ó 10 dígitos | Must have 9 or 10 digits",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#email_1_33").on("blur change", function() {var errorMessages = [];var input = $("#email_1_33");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#email_1_33").on("blur change", function() {var errorMessages = [];var input = $("#email_1_33");var val = input.val();if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();var pattern = new RegExp(/^(([^()\[\]\.,;:\s@"]+(\.[^()\[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i);if (val != "" && !pattern.test(String(val).toLowerCase())) {var errorMessage = buildErrorMessage("Ingrese un correo válido | Please enter a valid email",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("input[name='radioButton_1_23_value']").on("blur change", function() {var errorMessages = [];var input = $("input[name='radioButton_1_23_value']");var val = input.filter(':checked').val();val = typeof val == "undefined" ? "" : val;if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}});$("#termsOfUse_1_34").on("blur change", function() {var errorMessages = [];var input = $("input[name='termsOfUse_1_34']");var val = input.filter(':checked').val();val = typeof val == "undefined" ? "" : val;if(input.is(":visible") || input.attr("type")=="hidden"){val = String(val).trim();if (val == "") {var errorMessage = buildErrorMessage("Campo requerido / This field is required",val);errorMessages.push(errorMessage);}if (errorMessages.length > 0) {isFormValid=false;var formGroup = input.closest(".mf-form-group");formGroup.addClass("mf-has-error").find(".mf-error").html(errorMessages[0]).show();}}}); }); })(jQuery);