I'm trying to make a login in html and validate if the username and password are correct with a javascript (for the moment I only see if username and password are the same), and depending on whether they are correct or not redirect me to one page or another, the problem is that I have not managed to make a script that works for me, the data entry I have it in a form that looks like this:
<div class="container">
<form method="POST" name="formLogin" action="logeado.html" onsubmit="login(userName,password)">
USERNAME<br>
<input type="text" name="userName" placeholder="Nombre de usuario"><br>
PASSWORD<br>
<input type="text" name="password" placeholder="Contraseña">
<br>
<input type="submit" name="btnLogin" value="Ingresar" onsubmit="login">
</form>
</div>
It's something simple but I just want to make it work, the issue is that if username and password are the same I want to redirect to "logeado.html", otherwise I want to stay in the current page that is "login. html "and send me an error alert. I am using visual code with html5. I hope you can help me, thank you very much!