function init() { var register = document.getElementById('register-form'); if (register) { register.onsubmit = function(e) {return validateRegister(this);} register.elements["name"].onchange = function(e) {return checkLoginName(this);} register.elements["email"].onchange = function(e) {return checkLoginEmail(this);} } } function validateRegister(item) { var name = item.elements["name"]; var email = item.elements["email"]; var pwd = item.elements["pwd"]; var accept = item.elements["accept"]; if (!accept.checked) { alertPopup("Debes aceptar las condiciones de uso para poder registrate"); return false; } if (name.value.length < 8) { alertPopup("El nombre es demasiado corto. Recuerda que tienes que poner tu nombre real con apellidos."); return false; } if (email.value == '') { alertPopup("El email esta vacio"); return false; } if (pwd.value.length < 6) { alertPopup("La contrasena es demasiado corta"); return false; } return true; } function checkLoginName(item) { var name = item.value; var where = document.getElementById('warn-name'); if (where) { where.style.display = 'none'; } xmlhttpPost('/action/a_check_username/', 'name='+encodeURIComponent(name), warnIfError); return false; } function checkLoginEmail(item) { var email = item.value; var where = document.getElementById('warn-email'); if (where) { where.style.display = 'none'; } xmlhttpPost('/action/a_check_email/', 'email='+encodeURIComponent(email), warnIfError); return false; } function warnIfError(resp) { var result = splitEx(resp, ' ', 3); if (result[0] != 'ok') { var where = document.getElementById('warn-' + result[1]); if (where) { where.style.display = 'block'; where.innerHTML = result[2]; } } } addLoadEvent(init);