0
Javascript forwarding does not work with external script.
I have a page with the following code:
<input type="text" name="login" id="login">
<input type="password" name="senha" id="senha">
<button type="button" id="btnEntrar">Entrar</button>
<script src="js/functions-index.js"></script>
On my page functions-index.js:
var btnEntrar = document.getElementById('btnEntrar');
var login = document.getElementById('login');
var senha = document.getElementById('senha');
btnEntrar.addEventListener('click', function(){
if(login.value ==''){
alert("Preencha o campo email");
}
else if(login.senha == ''){
alert("Preencha o campo senha");
}
else if(login.senha === '123'){
console.log(login.value);
location.href = "pag2.html";
}
});
However, redirecting does not work.Not even with href
, location
, replace
and etc
No error is returned