0
My question is:
When clicking the send button If the name field is empty, notify in message in front of the input: message "Name not specified. Enter the name to access",
function validar() {
var nome = form1.nome.value;
var senha = form1.senha.value;
if (nome == "") {
alert ('Nome não informado. Digite o nome para ter acesso');
form1.nome.focus();
return false;
}
}
<html>
<head>
<title>Java validação</title>
</head>
<body>
<fieldset>
<legend> Informe os dados de login </legend>
<form name="form1" action="enviar.php" method="post">
Nome:
<input name="nome" type="text"><br /><br />
Senha:
<input name="senha" type="password"><br /><br />
<input type="submit" onclick="return validar()">
</form>
</fieldset>
</body>
</html>
I put an Alert, but it’s the way I know it.
Because you don’t put one
*
and says it is mandatory? Better than wasting time making error message. By good UX avoid that the user makes the mistake, and do not focus on making a message saying that it error ;)– hugocsl
the requirement is a message even.
– Matheus Pereira