Originariamente inviato da settimosenso
Ciao, scusa ma peche' non usi una semplice funzione javascript per la validazione ?? esempio:

<table align="center" border="0">
<form method="post" name="modulo">
<tr>
<td colspan="2" align="center">Registrazione al servizio
Tutti i campi sono obbligatori
</td>
</tr>
<tr>
<td>Nome</td>
<td><input type="text" name="nome"></td>
</tr>
<tr>
<td>Cognome</td>
<td><input type="text" name="cognome"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="button" value="Invia" onClick="Modulo()">
</td>
</tr>
</form>
</table>

poi crei una funzione javascript che inserirai tra i TAG <head></head>

<script language="javascript">
<!--
function Modulo() {
// Variabili associate ai campi del modulo
var nome = document.modulo.nome.value;
var cognome = document.modulo.cognome.value;
var email = document.modulo.email.value;
// Espressione regolare dell'email
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
//Effettua il controllo sul campo NOME
if ((nome == "") || (nome == "undefined")) {
alert("Il campo Nome è obbligatorio.");
document.modulo.nome.focus();
document.modulo.nome.style.backgroundColor="red";
return false;
}
//Effettua il controllo sul campo COGNOME
else if ((cognome == "") || (cognome == "undefined")) {
alert("Il campo Cognome è obbligatorio.");
document.modulo.cognome.focus();
document.modulo.cognome.style.backgroundColor="red ";
return false;
}
else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
alert("Inserire un indirizzo email corretto.");
document.modulo.email.select();
document.modulo.email.style.backgroundColor="red";
return false;
}
//INVIA IL MODULO
else {
document.modulo.action = "e_insertContact.php ";
document.modulo.submit();
}
}
//-->
</script>

diciamo che è un idea, però ho un piccolo problema che io all'interno del form ho una cosa simile ad un certo punto:

Codice PHP:
<tr>
            <td width="40%" >Tipo Contatto</td>
              <td width="60"><select name="IDTipoContatto" size="1"> 
                 <?php 
                    
                    $db 
openDB();
                    
$campi 'IDTipoContatto,TipoContatto';
                    
$result interrogaCampiDaTabella($dbtipologia_contatto$campi);
                               
                        while(
$row mysql_fetch_row($result))
                        {
                            echo 
"<option value=$row[0]$row[1] </option>"
                        }
                            
                    
mysql_free_result($result);
                    
mysql_close($db);    
                
?>              
              </select>
              </td>
        </tr>
che praticamente mi riempie un campo di selezione con dei valori pescati dal db, posso inserirli lo stesso?