1
I have this small form that should send the data filled in it to the page "cad_real_qm.php". However, I have a javascript function that checks if some fields are null and if so, will issue an alert. However, when I test giving Ubmit in the empty form, it displays the first alert and registers the empty fields in "cad_real_qm.php". How do I access the already mentioned page only if all the fields I need are filled?
Follows the code:
<form name="cad_ori" class="got" method="GET" onSubmit="verifica()" action="cad_real_qm.php" >
<br>
<center>
<a class="got"> 1° server: </a>
<input type="text" maxlength="15" placeholder="Servidor 1" name="ser1" style="width:100px;"/>
<a class="got"> 2° server: </a>
<input type="text" maxlength="15" placeholder="Servidor 2" name="ser2" style="width:100px;"/>
<a class="got"> 3° server: </a>
<input type="text" maxlength="15" placeholder="Servidor 3" name="ser3" style="width:100px;"/>
<br /><br /><br />
<a class="got"> Ori: </a>
<input type="text" maxlength="4" placeholder="Origem" name="ori" style="width:100px;"/>
<a class="got"> Papel: </a>
<input type="text" maxlength="20" placeholder="Papel" name="pap" style="width:100px;"/>
<br /><br /><br />
<button class="css_btn_class" type="submit">Cadastrar</button>
</center>
<br />
</form>
<script>
function verifica() {
if (document.cad_ori.ser1.value =='') {
alert("Insira o ip do servidor 1!");
return;
} else if (document.cad_ori.ori.value =='') {
alert("Insira a origem!");
return;
} else if (document.cad_ori.pap.value =='') {
alert("Insira o papel!");
return;
}
}
</script>
Aaaah vlw man, that was me :D
– Geraldão de Rívia