function validate() {
    var error = document.getElementById('error');
    var located = new URLSearchParams(location.search);
    
    //validar pwd
    var valPwd = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*\_\-\(\)\,\.])(?=.{8,31}$)/g;
    
    var params = {
        pwd: document.getElementById('firstPw').value,
        confirmPwd: document.getElementById('secondPw').value,
        hash: located.get('hash'),
    };

    if (params.pwd === '' && params.confirmPwd === '') {
        error.innerHTML = "Los campos no pueden estar vac\u00EDos";
    } else if(params.pwd != params.confirmPwd) {
        error.innerHTML = "Las contrase\u00F1as no coinciden";
    } else if(params.pwd.length < 8){
        error.innerHTML = `La contrase\u00F1a debe contener m\u00EDnimo 8 caracteres`;
        /*if(!valPwd.test(params.pwd)){
        error.innerHTML = `La contrase\u00F1a debe contener:<br>
        -Entre 8 y 32 caracteres.<br>
        -Contener m\u00EDnimo 1 may\u00FAscula, min\u00FAscula y n\u00FAmero.<br>
        -Contener 1 car\u00E1cter especial como * \ ( ) -.`;*/
    }else{
        error.innerHTML = "";
        params.pwd = MD5(params.pwd);
        loadScreen();
        callWS("GET", "login/recover", params, respx);
    }
    
    function respx(status, respText){
        console.log(status);
        closeLoad();
        if ( status == 200 ){
            gotoPage('login','main',{});
        } else if ( status == 401 ) {
            error.innerHTML = "Hash incorrecto";
        }
    }
}

window.onload = function carga() {
    
    //Regresar
    document.getElementById('changePass').addEventListener("click", function(){
        validate();
    });
    
    //Detect enter
    document.body.addEventListener("keydown",function (e) {
        if (e.keyCode === 13) {
            validate();
        }
    });
}