-1
How do I get this login to accept 3 users? And being a valid user it directs to the index?
function Login() {
var done = 0;
var usuario = document.getElementsByName('username')[0].value;
usuario = usuario.toLowerCase();
var senha = document.getElementsByName('password')[0].value;
seha = senha.toLowerCase();
if (usuario == "bcf" && senha == "bcf") {
window.location = "index.html";
done = 1;
}
if (done == 0) {
alert("Dados incorretos, tente novamente");
}
}
<div class="row">
<div class="container login col-xs-12 col-sm-offset-2 col-sm-8 col-md-offset-3 col-md-6 col-lg-offset-4 col-lg-4">
<br />
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="title-login">Login</h1>
</div>
<div class="panel-body">
<form method="post">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"> <i
class="glyphicon glyphicon-user" style="width: auto"></i>
</span> <input id="txtUsuario" runat="server" type="text" class="form-control" name="username" placeholder="Usuário" required="" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"> <i
class="glyphicon glyphicon-lock" style="width: auto"></i>
</span> <input id="txtSenha" runat="server" type="password" class="form-control" name="password" placeholder="Senha" required="" />
</div>
</div>
<!--div class="alert alert-danger">
<strong>Atenção!</strong> Usuário e/ou senha incorretos.
</div-->
<div>
<input class="btn btn-xm btn-block btn-entrar" type="submit" value="Entrar" onclick="Login()" />
</div>
</form>
</div>
</div>
</div>
</div>
You are entering the password in lowercase?
– Victor Stafusa
The two current responses already mention this, but I will insist: you are aware that the safety of this method is zero, right? Anyone who knows how to work the browser console or display the source code will be able to see the login list and password. There is no 100% secure solution in client-size JS, login is to be handled on the server.
– bfavaretto
I’m just exercising my js because of college
– Isa
Ok Isa, I just wanted to make sure that you knew what you were doing. I’ll keep the note up for unsuspecting ones to get here by google.
– bfavaretto
I asked if you type the passwords in lower case because of this:
seha = senha.toLowerCase();
- Note that you usedseha
without the lettern
.– Victor Stafusa