I'm having a validation error, when I hit the input
of submit
button it does not test the function
of JavaScript and it goes right where action
is going to go.
<HTML>
<HEAD>
<TITLE>Cadastro</title>
<script language="JavaScript">
function validaFormCadastro() {
d = document.form_cadastro;
if (d.NOME.value == "") {
alert("O campo NOME deve ser preenchido!");
d.NOME.focus();
return false;
}
if (d.NOMEUSUARIO.value == "") {
alert("O campo NOME DE USUARIO deve ser preenchido!");
d.NOMEUSUARIO.focus();
return false;
}
if (d.RM.value == "") {
alert("O campo RM deve ser preenchido!");
d.RM.focus();
return false;
}
if (d.SENHA.value == "") {
alert("O campo SENHA deve ser preenchido!");
d.SENHA.focus();
return false;
}
}
</script>
</head>
<body>
<form name="form_cadastro" action="salvar_aluno.php" method="get">
<table border='1'>
<tr>
<td>
<label>Nome completo</label>
</td>
<td>
<input type="text" name="NOME">
<br>
</td>
</tr>
<tr>
<td>
<label>Nome de Usuario</label>
</td>
<td>
<input type="text" name="NOMEUSUARIO">
<br>
</td>
</tr>
<tr>
<td>
<label>RM</label>
</td>
<td>
<input type="text" name="RM">
<br>
</td>
</tr>
<tr>
<td>
<label>SENHA</label>
</td>
<td>
<input type="password" name="SENHA">
<br>
</td>
</tr>
</table>
<p>
<input type="submit" name="botao_comando" value="CADASTRAR" onclick="return validaFormCadastro()">
</form>
</body>
</html>