Pessoal estou montando um login aqui em HTML,java Script e PHP deu tudo certo mas ele não está fazendo tratamento de erros exemplo se um Textbox ficar vazio ele teria que retornar um Alert para o usuário mas não está ocorrendo, se alguem puder me ajudar !
<HTML>
<HEAD>
</HEAD>
<BODY>
<script>
function teste(){
var login= document.getElementById("login").value;
var senha = document.getElementById("senha").value;
var cargo = document.getElementById("cbcargo").selectedIndex;
if(login == ""){
alert("LOGIN NÃO PREENCHIDO");
}
if(senha == ""){
alert("SENHA NÃO PREENCHIDO");
}
if(cargo == ""){
alert("CARGO NÃO PREENCHIDO");
}
//var msg = <?$acesso?>;
//alert(msg);
// }
</script>
</BODY>
<form name ="script" action ="login.php" method ="POST" ><center>
<table>
<tr>
<td>LOGIN :</td>
<td><input id ="login" name ="log" type = "text"></td>
</tr>
<tr>
<td>SENHA :</td>
<td><input id ="senha" name ="sen" type ="password"></td>
</tr>
<tr>
<td></td>
<td><select name="cbcargo" size="1" onChange="displaysub()">
<option value="0"></option>
<option value="1">Administrador</option>
<option value="2">Funcionário</option></td>
</select>
</tr>
<tr>
<td></td>
<td><input type ="submit" value ="Verificar" onClick = "teste();">
<input type ="reset" value ="Limpar"></td>
</tr>
</table>
</center></form>
</HTML>
o button deveria entrar no método teste() mas parece que não está passando e está indo direto para o PHP