Good,
I'm having a problem with an html form where I want the data not to be empty for DB. I have JavaScript but it is not working properly.
Jsfield: link
Code:
<form action="NovoCliente.php" method="post" onsubmit="return validar();">
<p><label class="formulario">Nome </label><input type="text" name="Nome" size="50" maxlength="30"></p>
<p><label class="formulario">Password </label><input type="password" name="Password" size="50" maxlength="30"></p>
<p><label class="formulario">Número de BI </label><input type="Number" name="NumeroBI" size="50" maxlength="30"></p>
<p><label class="formulario">Morada </label><input type="text" name="Morada" size="50" maxlength="30"></p>
<p><label class="formulario">Telefone </label><input type="text" name="Telefone" size="50" maxlength="30"></p>
<p><label class="formulario">Data de Nascimento </label><input type="Date" name="DataNasc"></p>
<p><label class="formulario">Email </label><input type="text" name="Email" size="50" maxlength="30"></p>
<input type="reset" value="Limpar">
<input type="submit">
</form>
Script:
<script>//Script para validar dados do Registo
function validar(){
if(document.ficha.nome.value.length == 0)
{
alert("Falta nome");
return false;
}
if( isNaN (document.ficha.numbi.value.length == 0))
{
alert("Sรณ numeros");
return false;
}
else if (document.ficha.numbi.value.length < 8)
{
alert("Faltam numeros");
return false;
}
if(document.ficha.correio.value.indexOf("@") == -1)
{
alert("Email Invalido");
return false;
}
}
</script>