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($) { $.fn.inputFilter = function(inputFilter) { return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function() { if (inputFilter(this.value)) { this.oldValue = this.value; this.oldSelectionStart = this.selectionStart; this.oldSelectionEnd = this.selectionEnd; } else if (this.hasOwnProperty("oldValue")) { this.value = this.oldValue; this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd); } else { this.value = ""; } }); }; }(jQuery)); $(function(){ $("#msform_donar select[name='crm_contacto[comuna]']").change(function(){ $.post('https://haztesocio.ayudabomberos.cl', { "_ajax_":'getCondicionesNew', "comuna_id": $(this).val() }, function(dataSet) { var payku = false; var option = ''; $("input[name='institucion_id']").val(dataSet.institucion_id); if($("#externo").val() == 1) { $("#form_wbpay_donar").attr("action",dataSet.url) } //$("#MedioPago").html(option); //$("#MedioPago").change(); },"jsonp"); }); if(getParameterByNameTrack("utm_source")) { setFomsParam("utm_source",getParameterByNameTrack("utm_source")); } if(getParameterByNameTrack("utm_medium")) { setFomsParam("utm_medium",getParameterByNameTrack("utm_medium")); } if(getParameterByNameTrack("utm_campaign")) { setFomsParam("utm_campaign",getParameterByNameTrack("utm_campaign")); } if(getParameterByNameTrack("utm_id")) { setFomsParam("utm_id",getParameterByNameTrack("utm_id")); } if(getParameterByNameTrack("utm_term")) { setFomsParam("utm_term",getParameterByNameTrack("utm_term")); } if(getParameterByNameTrack("utm_content")) { setFomsParam("utm_content",getParameterByNameTrack("utm_content")); } $("#msform_donar input[name='monto_doancion']").click(function(){ var select = document.getElementById('monto_seleccionado'); var opts = select.options; for (var opt, j = 0; opt = opts[j]; j++) { if (opt.value == $(this).data("val")) { select.selectedIndex = j; break; } } if($(this).data("val")=="Otro"){ $(this).val(1000) } $("#msform_donar #monto_seleccionado").change(); }); $("#otromonto").keypress(function(){ $("#monto_otro").val( $("#otromonto").val()); }); $("#msform_donar").submit(function(e){ e.preventDefault(); if($("#msform_donar .metodo_pago:checked").length < 1) { alert("Seleccione el medio de pago."); return false; } var metodo = $("#msform_donar .metodo_pago:checked").val(); // console.log(metodo); // $("#msform_donar #enviar").prop("disabled",true).val("Cargando..."); if(metodo == 1) { var url = "./"; if($("#externo").val() == 1) { url = $("#form_wbpay_donar").attr("action"); $.post(url,$("#msform_donar").serializeArray(),function(e){ if(e.ok == "true") { $("#form_wbpay_donar").attr("action",e.url); $("#form_wbpay_donar #token_ws ").val(e.token); $("#form_wbpay_donar").submit() } else { alert("Web pay no disponible"); } },"jsonp") } else { $.post(url,$("#msform_donar").serializeArray(),function(e){ if(e.ok == "true") { $("#form_wbpay_donar").attr("action",e.url); $("#form_wbpay_donar #token_ws ").val(e.token); $("#form_wbpay_donar").submit() } else { alert("Web pay no disponible"); } },"json") } } else if(metodo == 3) { //125 // console.log("🚀 ~ file: Js.js:236 ~ $.post ~ $(#externo).val():", $("#externo").val()) $.post("https://santiago.ayudabomberos.cl",$("#msform_donar").serializeArray(),function(e){ //$("#form_wbpay_donar").attr("action","payku.html"); if($("#externo").val() == 1) { var action = $("#form_wbpay_donar").attr("action"); action = action+"/payku.html"; // alert(action); $("#form_wbpay_donar").attr("action",action); } else { $("#form_wbpay_donar").attr("action","payku"); } $("#form_wbpay_donar #token_ws").val(e.val); $("#form_wbpay_donar").submit() },"jsonp") } else if(metodo == 4) { $.post("https://santiago.ayudabomberos.cl",$("#msform_donar").serializeArray(),function(e){ if($("#externo").val() == 1) { var action = $("#form_wbpay_donar").attr("action"); action = action+"/bitcoin.html"; alert(action); return false; } else { $("#form_wbpay_donar").attr("action","bitcoin"); } $("#form_wbpay_donar #token_ws").val(e.val); $("#form_wbpay_donar").submit() },"jsonp") } return false; }); if(getParameterByName("vid")) { $.cookie('vid', getParameterByName("vid")); } if($.cookie('vid') != undefined && $.cookie('vid') != "" ) { $("#msform_donar").append(''); } if(getParameterByName("uid")) { $.cookie('uid', getParameterByName("uid")); } if($.cookie('uid') != undefined && $.cookie('uid') != "" ) { $("#msform_donar").append(''); } $("#msform_donar #monto_seleccionado").change(function(){ if($(this).val() == "Otro") { //$("#msform_donar #monto_otro").removeClass("hide"); // $("#msform_donar #monto_otro").addClass("required") // $("#msform_donar #monto_otro").attr("required","required") // $("#msform_donar #monto_otro").val(1000); } else { $("#msform_donar #monto_otro").removeClass("required") $("#msform_donar #monto_otro").addClass("hide"); $("#msform_donar #monto_otro").removeAttr("required"); $("#msform_donar #monto_otro").val(""); } }); $("body").on("blur",".email",function(){ if(!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($(this).val())) { if($(this).val()!=""){ alert("Email inválido"); } } }); $(".rut").Rut({ on_error: function(){ alert("Rut no valido"); } }); $(".numero").inputFilter(function(value) { return /^\d*$/.test(value); // Allow digits only, using a RegExp }); function deseleccionarRadios() { var radios = document.getElementsByName("monto_donacion"); var textoInput = document.getElementById("otromonto"); if (textoInput === document.activeElement) { for (var i = 0; i < radios.length; i++) { radios[i].checked = false; } } } }) 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(){ $("#donar_puntual").click(function(){ $("#msform").addClass("hide"); $("#msform_donar").removeClass("hide"); $("#msform .datos_formulario").each(function(){ $("#msform_donar [name='"+$(this).attr("name")+"']").val($(this).val()) }); }); $("#msform select[name='crm_contacto[comuna]']").change(function(){ $.post('https://haztesocio.ayudabomberos.cl', { "_ajax_":'getCondicionesNew', "comuna_id": $(this).val() }, function(dataSet) { var payku = false; $('#msform #MedioPago').find('option').remove(); var option = ''; $('#msform #Medio_Pago').html(""); $("#msform input[name='institucion_id']").val(dataSet.institucion_id); $("#msform #priva2").html(Base64.decode(dataSet.legal)); $.each(dataSet.mdp, function(i, val) { if(val == "Payku") { option+= ''; } else { option+= ''; } }); $("#msform #MedioPago").html(option); $("#msform #MedioPago").change(); },"jsonp"); }); $("#msform #textp_tipo_pago").blur(function(){ $("#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($("#msform #MedioPago").val()+" inválida."); obj.val("") } $("#msform .submit").prop("disabled",false); $("#msform .submit").val("Enviar"); },"jsonp"); }); 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 $("#msform .next").click(function(){ if(animating) return false; animating = true; var obliga = Array(); var valid = true; var paso = 0; $("#msform #paso_1_fieldset").find(".required").each(function(){ paso = 10; /*if($(this).val() == "") { animating = ""; valid = false; obliga.push($(this).attr("placeholder")); }*/ if($(this).attr("type")=="checkbox"){ //alert($(this).prop("checked")); if(!$(this).prop("checked")){ animating = ""; valid = false; obliga.push($(this).attr("placeholder")); } }else{ if($(this).val() == "") { animating = ""; valid = false; obliga.push($(this).attr("placeholder")); } } }); obliga = obliga.join(", "); if(valid == false) { alert("Los siguientes campos son obligatoros : "+obliga); return false; } if(paso == 10) { $.post("https://santiago.ayudabomberos.cl/?paso=10",$("#msform").serializeArray(),function(e){ $("#msform input[name='consulta_id']").val(e.consulta_id); $("#msform #consulta_id").val(e.consulta_id); },"jsonp"); } current_fs = $(this).parent(); next_fs = $(this).parent().next(); //activate next step on progressbar using the index of next_fs $("#msform #progressbar li").eq($("fieldset").index(next_fs)).addClass("active"); //show the next fieldset next_fs.show(); //hide the current fieldset with style current_fs.animate({opacity: 0}, { step: function(now, mx) { //as the opacity of current_fs reduces to 0 - stored in "now" //1. scale current_fs down to 80% scale = 1 - (1 - now) * 0.2; //2. bring next_fs from the right(50%) left = (now * 50)+"%"; //3. increase opacity of next_fs to 1 as it moves in opacity = 1 - now; current_fs.css({ 'transform': 'scale('+scale+')', 'position': 'absolute' }); next_fs.css({'left': left, 'opacity': opacity}); }, duration: 800, complete: function(){ current_fs.hide(); animating = false; }, //this comes from the custom easing plugin easing: 'easeInOutBack' }); }); $("#msform .previous").click(function(){ if(animating) return false; animating = true; current_fs = $(this).parent(); previous_fs = $(this).parent().prev(); //de-activate current step on progressbar $("#msform #progressbar li").eq($("fieldset").index(current_fs)).removeClass("active"); //show the previous fieldset previous_fs.show(); //hide the current fieldset with style current_fs.animate({opacity: 0}, { step: function(now, mx) { //as the opacity of current_fs reduces to 0 - stored in "now" //1. scale previous_fs from 80% to 100% scale = 0.8 + (1 - now) * 0.2; //2. take current_fs to the right(50%) - from 0% left = ((1-now) * 50)+"%"; //3. increase opacity of previous_fs to 1 as it moves in opacity = 1 - now; current_fs.css({'left': left}); previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity}); }, duration: 800, complete: function(){ current_fs.hide(); animating = false; }, //this comes from the custom easing plugin easing: 'easeInOutBack' }); }); /*FIN*/ $("#msform #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 += "-"; } //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 } $("#msform #"+id).val(phoneValue); } function is_digit(input){ if (isNaN(input)) { return false; }else{ return true; } } $("#msform").submit(function(e){ e.preventDefault(); var obliga = Array(); var valid = true; if($("#msform #MedioPago").val() == "Cta. Cte. Bancaria" ) { var rut = $("#msform input[name='crm_contacto[rut]']").val(); var cuenta = $("#msform #textp_tipo_pago").val(); rut = rut.split(".").join(""); rut = rut.split("-").join(""); cuenta = cuenta.split(".").join(""); cuenta = cuenta.split("-").join(""); //se quita validacion el 22 de 09 de 2020, RI. /* if(rut.indexOf(cuenta,0)>=0) { alert("Favor ingresar Cuenta Corriente, no podemos procesar una Cuenta Rut."); return false; }*/ } $("#msform #paso_2_fieldset").find(".required").each(function(){ if($(this).val() == "") { animating = ""; valid = false; obliga.push($(this).attr("placeholder")); } }); obliga = obliga.join(", "); if(valid == false) { alert("Los siguientes campos son obligatoros : "+obliga); return false; } $.post("https://santiago.ayudabomberos.cl",$(this).serializeArray(),function(e){ 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(); }); // $('#loginForm').removeClass("hide"); // alertify.genericDialog ( $('#loginForm')[0]).set({onshow:null, onclose:function(){ location.reload();}}); } },"jsonp"); return false; }); $("#msform #tipo_pago").change(function(e){ if($("#msform #MedioPago").val() == "Payku") { e.preventDefault(); if($(this).data("variable") == $(this).val()) { $("#msform #monto_otro").removeClass("hide"); $("#msform #monto_otro").addClass("required"); } else { $("#msform #monto_otro").addClass("hide"); $("#msform #monto_otro").removeClass("required"); $("#msform #monto_otro").val(""); } return false; } }); $("#msform #MedioPago").change(function(){ if($("#msform #MedioPago").val() == "Tarjeta de Débito") { $("#msform #tipo_pago").removeClass("required"); $("#msform #tipo_pago").addClass("hide"); $("#msform #tipo_pago_label").addClass("hide"); $("#msform #textp_tipo_pago").removeClass("required"); $("#msform #textp_tipo_pago").addClass("hide"); $("#msform #titular_telefono").removeClass("required"); $("#msform #titular_telefono").addClass("hide"); $("#msform #rut_titular_telefono").removeClass("required"); $("#msform #rut_titular_telefono").addClass("hide"); $("#msform #fecha_vencimiento").addClass("hide"); $("#msform #fecha_vencimiento_mes").removeClass("required"); $("#msform #fecha_vencimiento_anno").removeClass("required"); return false; } else { /* $("#monto_seleccionado").removeClass("hide"); $("#monto_seleccionado").addClass("required"); $("#monto_otro").addClass("hide"); $("#monto_otro").removeClass("required"); */ } //Número Cuenta/Tarjeta/Movistar: $("#msform #textp_tipo_pago").val(""); $("#msform #tipo_pago_label").html(""); $titulo = "Seleccione Medio de Pago"; $("#msform #datos_pago_delefono").addClass("hide") $("#msform #rut_titular_telefono").removeClass("required") $("#msform #titular_telefono").removeClass("required") $("#msform #tipo_pago").removeClass("required") $("#msform #textp_tipo_pago").removeClass("required") $("#msform #fecha_vencimiento").addClass("hide") $("#msform #fecha_vencimiento_mes").removeClass("required") $("#msform #fecha_vencimiento_anno").removeClass("required") var option = ''; if($(this).val() == "Tarjetas de Crédito") { $("#msform #tipo_pago_label").html("Tarjeta"); $("#msform #tipo_pago").attr("placeholder","Tarjeta"); $titulo = "Número de Tarjeta"; $("#msform #fecha_vencimiento").removeClass("hide") $("#msform #fecha_vencimiento_mes").addClass("required") $("#msform #textp_tipo_pago").addClass("required") $("#msform #fecha_vencimiento_anno").addClass("required") option = ''; } else if($(this).val() == "Cta. Cte. Bancaria") { $("#msform #tipo_pago_label").html("Banco"); $("#msform #tipo_pago").attr("placeholder","Banco"); $("#msform #tipo_pago").addClass("required") $("#msform #textp_tipo_pago").addClass("required") $titulo = "Número de Cuenta"; option = ''; } else if($(this).val() == "Cuenta Rut") { $("#msform #tipo_pago_label").html("Banco"); $("#msform #tipo_pago").attr("placeholder","Banco"); $("#msform #tipo_pago").addClass("required") $("#msform #textp_tipo_pago").addClass("required") $titulo = "Número de Cuenta"; option = ''; } else if($(this).val() == "Cuenta Vista") { $("#msform #tipo_pago_label").html("Banco"); $("#msform #tipo_pago").attr("placeholder","Banco"); $("#msform #tipo_pago").addClass("required") $("#msform #textp_tipo_pago").addClass("required") $titulo = "Número de Cuenta"; option = ''; } else if($(this).val() == "Tarjetas de Casas Comerciales") { $("#msform #tipo_pago_label").html("Casa Comercial"); $("#msform #msform #tipo_pago").attr("placeholder","Casa Comercial"); $("#tipo_pago").addClass("required") $("#msform #textp_tipo_pago").addClass("required") $titulo = "Número de Tarjeta"; /*if( $('input[name="institucion_id"]').val() == 113 || $('input[name="institucion_id"]').val() == 114 || $('input[name="institucion_id"]').val() == 115 || $('input[name="institucion_id"]').val() == 116 || $('input[name="institucion_id"]').val() == 117 ) { */ option = ''; /*} else { option = ''; }*/ } else if($(this).val() == "Enel") { //$("#tipo_pago").removeClass("required") $("#msform #tipo_pago_label").html("Compañia"); $("#msform #tipo_pago").attr("placeholder","Compañia"); $("#msform #tipo_pago").addClass("required") //$("#textp_tipo_pago").addClass("required") $("#msform #rut_titular_telefono").addClass("required") $("#msform #titular_telefono").addClass("required") $titulo = "Número de Cliente ENEL"; $("#msform #datos_pago_delefono").removeClass("hide") option = ''; } $("#msform #textp_tipo_pago").attr("placeholder",$titulo); $("#msform #tipo_pago").html(option); if($(this).val()==""){ $("#msform #tipo_pago").addClass("hide"); $("#msform #textp_tipo_pago").addClass("hide"); $("#msform #label_tipo_pago").addClass("hide"); }else{ $("#msform #tipo_pago").removeClass("hide"); $("#msform #textp_tipo_pago").removeClass("hide"); $("#msform #label_tipo_pago").removeClass("hide"); } }); $(".rut").Rut({ on_error: function(){ alert("Rut no valido"); } }); $(".numero").keydown(function (event) { return NumericField($(this).val(), event, true); }); $("#msform #monto_otro").blur(function(){ if($("#msform #MedioPago").val() == "Payku") { if($(this).val() < 3000) { alert("El monto debe ser superior a $3.000"); $(this).val(""); } return false; } if($(this).val() < 3000) { alert("El monto debe ser superior a $3.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(); } $("#msform #comuna_falp").change(); }); $("#msform #monto_seleccionado").change(function(){ if($(this).val() == "Otro") { $("#msform #monto_otro").removeClass("hide"); $("#msform #monto_otro").addClass("required") } else { $("#msform #monto_otro").removeClass("required") $("#msform #monto_otro").addClass("hide"); } 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($("#msform #comuna_falp").attr("id") == "comuna_falp") { $("#msform #comuna_falp").change(); } else { $("#msform #MedioPago").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); } $("#msform #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']; //console.log(comunas); 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(); } $('#msform #MedioPago').prop('selectedIndex',0); $('#msform #MedioPago').change(); }); if ( $("#msform #comuna_falp").length > 0 ) { setTimeout(function(){ $("#msform #comuna_falp").select2(); },400); } $("body").on("blur",".email",function(){ if(!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($(this).val())) { $(this).val(""); alert("Email inválido"); } }); 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 } }