function validar_form_imo(){ if(document.getElementById('acepto_imo').checked){ var msg=''; document.getElementById('nombre_form_imo').value = trim(document.getElementById('nombre_form_imo').value); document.getElementById('web_form_imo').value = trim(document.getElementById('web_form_imo').value); document.getElementById('tlf_form_imo').value = trim(document.getElementById('tlf_form_imo').value); if(document.getElementById('nombre_form_imo').value=="" || document.getElementById('nombre_form_imo').value=="Tu nombre") msg='Debe introducir un nombre\n'; msg=msg+comprobar_web(document.getElementById('web_form_imo')); msg=msg+comprobar_tlf(document.getElementById('tlf_form_imo')); if(msg==''){ document.getElementById('form_imo').submit(); }else{ alert(msg); } }else{ alert('Debe aceptar las condiciones para continuar'); } } function validar_cita(){ var msg=''; document.getElementById('nombre_form_popcont').value = trim(document.getElementById('nombre_form_popcont').value); document.getElementById('web_form_popcont').value = trim(document.getElementById('web_form_popcont').value); document.getElementById('tlf_form_popcont').value = trim(document.getElementById('tlf_form_popcont').value); if(document.getElementById('nombre_form_popcont').value=="" || document.getElementById('nombre_form_popcont').value=="Tu nombre") msg='Debe introducir un nombre\n'; msg=msg+comprobar_web(document.getElementById('web_form_popcont')); msg=msg+comprobar_tlf(document.getElementById('tlf_form_popcont')); if(document.getElementById('acepto_form_popcont').checked==false) msg=msg+'\nDebe aceptar la pol\xedtica de privacidad'; var respuestas = new Array("|4|cuatro|four|quatre|","|5|cinco|five|cinc|","|madrid|","|2|dos|two|dues|","|8|ocho|eight|huit|"); var respuestaUsuario = "|"+document.getElementById('preg_form_popcont').value.toLowerCase()+"|"; var respuestaCorrecta = respuestas[document.getElementById('resp_form_popcont').value]; if(respuestaCorrecta.indexOf(respuestaUsuario)<0){ msg=msg+'\nLa respuesta a la pregunta Anti-Span es incorrecta'; document.getElementById('preg_form_popcont').value=document.getElementById('pregorig_form_popcont').value; } if(msg==''){ document.getElementById('form_popcont').submit(); }else{ alert(msg); } } function validar_contacto(){ if(document.getElementById('checkbox').checked){ var texto = ""; document.getElementById('nombre').value = trim(document.getElementById('nombre').value); document.getElementById('telefono').value = trim(document.getElementById('telefono').value); document.getElementById('web').value = trim(document.getElementById('web').value); document.getElementById('textarea').value = trim(document.getElementById('textarea').value); if(document.getElementById('nombre').value=="") texto = texto + "Debe rellenar el campo NOMBRE\n"; if(document.getElementById('telefono').value=="") texto = texto + "Debe rellenar el campo TELEFONO\n"; else if(texto += comprobar_tlf(document.getElementById('telefono'))) texto = texto + "\n"; if(document.getElementById('web').value=="") texto = texto + "Debe rellenar el campo WEB\n"; else if(texto += comprobar_web(document.getElementById('web'))) texto = texto + "\n"; if(document.getElementById('textarea').value=="") texto = texto + "Debe rellenar el campo DETALLES\n"; if(texto!="") alert(texto); else document.getElementById('formulario').submit(); }else{ alert('Debe aceptar la Pol\xedtica de Privacidad y la Pol\xedtica de Cookies'); } } function validar_afiliacion(){ var texto = ""; document.getElementById('nombre').value = trim(document.getElementById('nombre').value); document.getElementById('telefono').value = trim(document.getElementById('telefono').value); document.getElementById('web').value = trim(document.getElementById('web').value); document.getElementById('mail').value = trim(document.getElementById('mail').value); if(document.getElementById('nombre').value=="") texto = texto + "Debe rellenar el campo NOMBRE EMPRESA\n"; if(document.getElementById('telefono').value=="") texto = texto + "Debe rellenar el campo TELEFONO\n"; else if(texto += comprobar_tlf(document.getElementById('telefono'))) texto = texto + "\n"; if(document.getElementById('web').value=="") texto = texto + "Debe rellenar el campo PAGINA WEB\n"; else if(texto += comprobar_web(document.getElementById('web'))) texto = texto + "\n"; if(document.getElementById('mail').value=="") texto = texto + "Debe rellenar el campo E-MAIL\n"; else texto += comprobar_email(document.getElementById('mail')); if(texto!="") alert(texto); else document.getElementById('formulario').submit(); } function validar_boletin(){ var texto = ""; if(document.getElementById('checkbox_no').checked){ document.getElementById('formulario_boletin').submit(); }else{ if(document.getElementById('checkbox_boletin').checked){ document.getElementById('nombre_boletin').value = trim(document.getElementById('nombre_boletin').value); document.getElementById('mail_boletin').value = trim(document.getElementById('mail_boletin').value); if(document.getElementById('nombre_boletin').value=="" || document.getElementById('nombre_boletin').value=="Tu nombre") texto = texto + "Debe rellenar el campo NOMBRE\n"; if(document.getElementById('mail_boletin').value=="" || document.getElementById('mail_boletin').value=="Tu email") texto = texto + "Debe rellenar el campo E-MAIL\n"; else texto += comprobar_email(document.getElementById('mail_boletin')); if(texto!="") alert(texto); else document.getElementById('formulario_boletin').submit(); }else{ alert('Debe aceptar la Pol\xedtica de Privacidad y la Pol\xedtica de Cookies'); } } } /* FUNCION PARA CAMBIAR EL ESTILOS DE UN ELEMENTO */ function trim(cadena){ for(i=0; i=0; i=cadena.length-1){ if(cadena.charAt(i)==" ") cadena=cadena.substring(0,i); else break; } return cadena; } function cambiarClase(idCapa,clase) { document.getElementById(idCapa).className=clase; document.getElementById(idCapa).value = ""; } function descodificar(text){ text = text.replace("para", "@"); return text.replace("mail", ""); } function comprobar_web(campo){ var cadena = campo.value; var patron = /http:\/\//; if(patron.test(cadena)){ cadena = cadena.replace(patron,''); campo.value=cadena; } var patron = /https:\/\//; if(patron.test(cadena)){ cadena = cadena.replace(patron,''); campo.value=cadena; } if(cadena != "" && cadena!="Tu página web"){ var dominio = cadena.split('/'); var comprobacion = dominio[0]; var puntos = comprobacion.split('.'); if(puntos.length==1){ return 'Debe introducir una url correcta\n'; }else if(puntos.length>1){ if(puntos[0]=="www"){ if(puntos.length<=2 || puntos[puntos.length-1]==""){ return 'Debe introducir una url correcta\n'; } }else{ if(puntos[puntos.length-1]==""){ return 'Debe introducir una url correcta\n'; } } } return ''; }else{ return 'Debe introducir una url correcta\n'; } } function comprobar_tlf(campo){ if(isNaN(campo.value)) { return 'Debe introducir un n\xfamero de tel\xe9fono correcto'; } if(campo.value=="" || campo.value=="Tu teléfono"){ return 'Debe introducir un n\xfamero de tel\xe9fono correcto'; }else{ return ''; } } function comprobar_email(campo){ if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(campo.value)){ return ''; } else { return 'Debe introducir un E-MAIL correcto\n'; } } /* FUNCIONES PARA LA INFO ESPECIAL DE LOS PRODUCTOS SEO */ function cambiar_formulario(){ $('#popcont_contenedor').slideToggle('', function() { $("#popcont_contenedor2").slideUp(); $("#popcont_contenedor3").slideUp(); $("#popcont_contenedor4").slideUp(); $("#popcont_contenedor5").slideUp(); //Si añadimos otra tenemos que poner su correspondiente linea aqui }); } function mostrar_tabla(id){ window.scrollTo(0,0); document.getElementById('popcont_contenedor').style.display="none"; document.getElementById('popcont_contenedor'+id).style.display=""; $('.popup').click(); }