// Crea el objecto xmlhttp function creaAjax() { var xmlhttp = false; try { // versión de JavaScript superior a la 5 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { // objecto tradicional ActiveX if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlhttp; } // Procesa un XMLHttpRequest // IdObj: debe ser o
// response: XML o Texto (html) // method: GET o POST // str: string de valores que se enviaron (var=valor&var2=valor2...) function processAjax(URL,IdObj,response,method,str,funcion) { xmlhttp = creaAjax(); xmlhttp.open(method, URL); if (method == "POST") { // Añadimos un par etiqueta/valor al encabezado en el momento de enviarlo xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); } xmlhttp.onreadystatechange = function() { // readyState = estado actual del objecto, status = respuesta del servidor if (xmlhttp.readyState==1) { //document.getElementById(IdObj).innerHTML = "


  Cargando...

"; //document.getElementById(IdObj).style.background = "url('/images/basic/loading.gif') no-repeat center"; } else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if (response == "XML") { document.getElementById(IdObj).innerHTML = xmlhttp.responseXML; } else { document.getElementById(IdObj).innerHTML = xmlhttp.responseText; } if (funcion) eval(funcion); //document.getElementById(IdObj).style.background = ""; } } if (method == "GET") { xmlhttp.send(null); } else { xmlhttp.send(str); } } function checkform() { if (!document.registroFan.nombre.value) { alert('Debes introducir tu nombre'); document.registroFan.nombre.focus(); document.registroFan.nombre.style.backgroundColor = '#ffc4c4'; return false; } if (!document.registroFan.apellidos.value) { alert('Debes introducir tus apellidos'); document.registroFan.apellidos.focus(); document.registroFan.apellidos.style.backgroundColor = '#ffc4c4'; return false; } if (!document.registroFan.direccion.value) { alert('Debes introducir tu dirección'); document.registroFan.direccion.focus(); document.registroFan.direccion.style.backgroundColor = '#ffc4c4'; return false; } if (!document.registroFan.CP.value) { alert('Debes introducir tu CP'); document.registroFan.CP.focus(); document.registroFan.CP.style.backgroundColor = '#ffc4c4'; return false; } if (!document.registroFan.pais.value) { alert('Debes seleccionar tu país'); document.registroFan.pais.focus(); document.registroFan.pais.style.backgroundColor = '#ffc4c4'; return false; } var filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})+$/; if (!filtro.test(document.registroFan.email.value)) { alert('El formato de tu E-Mail es incorrecto.'); document.registroFan.email.style.backgroundColor = '#ffc4c4'; document.registroFan.email.focus(); return false; } if (document.registroFan.tipo.value == 3 && !document.registroFan.passwd.value) { alert('Debes introducir tu contraseña.'); document.registroFan.passwd.style.backgroundColor = '#ffc4c4'; document.registroFan.passwd.focus(); return false; } if (document.registroFan.tipo.value == 3 && document.registroFan.passwd.value != document.registroFan.passwd2.value) { alert('Tu contraseña no coincide en su repetición.'); document.registroFan.passwd2.style.backgroundColor = '#ffc4c4'; document.registroFan.passwd2.focus(); return false; } if (document.registroFan.acepto.checked == false) { alert('Debes aceptar la política de protección de datos'); return false; } return true; } function checkLogin() { var filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})+$/; if (!filtro.test(document.login.email.value)) { alert('El formato de tu E-Mail es incorrecto.'); document.login.email.style.backgroundColor = '#ffc4c4'; document.login.email.focus(); return false; } if (!document.login.passwd.value) { alert('Debes introducir tu contraseña'); document.login.passwd.focus(); document.login.passwd.style.backgroundColor = '#ffc4c4'; return false; } return true; }