How do I make messages in Javascript etc, when a warning appears?

-2

I want to know a code that when the person clicks on an OK button to appear a warning: "You are logged in!". If you do not get a warning: "You are not in the system, enter your Access information correctly!".

Would you help me?

    
asked by anonymous 05.09.2018 / 15:50

1 answer

0

This is very relative, there are several ways to do this, it depends on what you are using, whether there is a database with user login and password or if you want to use only JS, jQuery to do that.

Here's a basic example of whether the person logged in or not, using the data name = name123 and password = password123, you can see the result:

<!DOCTYPE html>
<html>
<head>
 <title>teste</title>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><style>#situacao{width:140px;height:70px;display:flex;justify-content:center;align-items:center;margin-top:40px;font-size:16px;}.logado{background-color:#65ff00;}.nLogado{background-color:#cc1212;}</style></head><body><label>Nome:</label><inputtype="text" name="nome" id="nome">
 <br>
 <label> Senha: </label>
 <input type="password" name="senha" id="senha">
 <br>
 <input type="submit" name="enviar" id="enviar" value="Logar">
 <div id="situacao"></div>
 <script>
  nome = "nome123";
  senha = "senha123";
  $("#enviar").click(function(){
    nomeDigitado = $("#nome").val();
    senhaDigitada = $("#senha").val();
    if(nomeDigitado == nome && senhaDigitada == senha){
     alert("Você está logado!");
     $("#situacao").html("Login com sucesso").addClass("logado");
     
    } else {
     alert("Você não esta no sistema, digite corretamente suas informações de Acesso!");
     $("#situacao").html("Login sem sucesso").addClass("nLogado");
    }
  });
 </script>
</body>
</html>
    
05.09.2018 / 16:16