With the help of the community, I created a file to redirect a user who typed his login to a webpage that receives the user this way:
The problem is that usually the user presses Enter when typing the text, so I tried to adjust the code so that pressing this key was redirected, but apparently the link is not receiving the variable.
Could you help me by pressing Enter or clicking Login after entering your login, the user is directed?
Here is my code:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Redirecionamento</title>
<div class="page-margin"></div>
<br>
<br>
<div align="center" class="welcome-form-div">
<div class="welcome-form">
<div class="html-logo">
<i class="icon-comments-alt"></i> Insira os números do seu
<br><b>login</b> <i>ou</i> <b>CPF</b> e clique em Entrar
<br>
<br>
</div>
<input type="text" id="username" name="username" size="20">
<input type="button" id="BotaoLogin" value="Entrar" onClick="redirecionar()">
</div>
<script language="javascript">
var username = document.getElementById("username");
username.addEventListener("keydown", function(e) {
if (e.keyCode == 13) {
redirecionar(e);
}
});
function redirecionar() {
if (username != "") {
window.location = "https://site.com.br/usuario"+username+"&empresa";
}
}
</script>