1
I have a page from login made with HTML and CSS and need to prevent login in it with Javascript under certain conditions, but still not caught much the trick of how to do this. I’m looking on the internet, but I haven’t been able to do it yet. At most I was able to do the pop-up if conditions are not met, but I was unable to prevent login with the return false
.
The conditions:
- Password must be greater than 6 characters;
- Email field cannot be empty;
My HTML code:
<html>
<head>
<meta charset="utf-8">
<title>
Login
</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body id="body">
<h1 id="titulo">
Logue-se por favor
</h1>
<form id="login-form">
<input id=email class=displayBlock type="email" placeholder="Email">
<input id="senha" class=displayBlock type="password" placeholder="Senha">
<label class=displayBlock >
<input type="checkbox"> Lembrar-me
</label>
<input id=entrar-btn type="submit" value="Entrar">
</form>
<script src="script.js"></script>
</body>
</html>
And what is your Javascript code? You used the event
onsubmit
of the validation form?– Woss
Thanks for the answer... the javascript tab is kind of blank for now, I was given this task, but I don’t understand any javascript yet, It’s kind of to learn in Main. The most I had managed to do on my own had been a pop-up warnings about the criteria not met. I did not make the event onsubmit, I will try now, thanks.
– Renan Soares Mendes