Salve a tutti, ho un piccolo problema: ovvero ho una pagina "register.php" che praticamente è la pagina di registrazione al sito... in questa pagina x prima cosa c'è un controllo sui campi; ovvero una cosa del genere :

Codice PHP:
/************************ SERVER SIDE VALIDATION **************************************/ /********** This validation is useful if javascript is disabled in the browswer ***/ if(empty($data['full_name']) || strlen($data['full_name']) < 4){ $err[] = "ERROR - Invalid name. Please enter atleast 3 or more characters for your name"//header("Location: register.php?msg=$err"); //exit(); } // Validate User Name if (!isUserID($data['user_name'])) { $err[] = "ERROR - Invalid user name. It can contain alphabet, number and underscore."; //header("Location: register.php?msg=$err"); //exit(); } // Validate Email if(!isEmail($data['usr_email'])) { $err[] = "ERROR - Invalid email address."; //header("Location: register.php?msg=$err"); //exit(); }  // Check User Passwords if (!checkPwd($data['pwd'],$data['pwd2'])) { $err[] = "ERROR - Invalid Password or mismatch. Enter 5 chars or more"; //header("Location: register.php?msg=$err"); //exit(); }  $user_ip = $_SERVER['REMOTE_ADDR']; // stores sha1 of password $sha1pass = PwdHash($data['pwd']); // Automatically collects the hostname or domain like example.com) $host = $_SERVER['HTTP_HOST']; $host_upper = strtoupper($host); $path = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); // Generates activation code simple 4 digit number $activ_code = rand(1000,9999); $usr_email = $data['usr_email']; $user_name = $data['user_name']; /************ USER EMAIL CHECK ************************************ This code does a second check on the server side if the email already exists. It queries the database and if it has any existing email it throws user email already exists *******************************************************************/ $rs_duplicate = mysql_query("select count(*) as total from users where user_email='$usr_email' OR user_name='$user_name'") or die(mysql_error()); list($total) = mysql_fetch_row($rs_duplicate); if ($total > 0){ $err[] = "ERROR - The username/email already exists. Please try again with different username and email."; //header("Location: register.php?msg=$err"); //exit(); } /***************************************************************************/ 
Adesso io avevo fatto una funzione in javascript x fare in modo che possa subito sapere quale campo sto sbagliando nella compilazione del form e cmq ho la possibilità di riavere i dati giusti precedentemente inseriti...

Codice PHP:
<script language="javascript"> function Modulo() { // Variabili associate ai campi del modulo var nome = document.modulo.full_name.value; var indirizzo = document.modulo.address.value; var nazione = document.modulo.country.value; var telefono = document.modulo.tel.value; var fax = document.modulo.fax.value; var website = document.modulo.web.value;  var user = document.modulo.user_name.value; var email = document.modulo.usr_email.value; var pass = document.modulo.pwd.value; var pass2 = document.modulo.pwd2.value;  // Resettiamo il colore di sfondo dei moduli  document.modulo.full_name.style.backgroundColor=""; document.modulo.address.style.backgroundColor=""; document.modulo.country.style.backgroundColor=""; document.modulo.tel.style.backgroundColor=""; document.modulo.fax.style.backgroundColor=""; document.modulo.web.style.backgroundColor=""; document.modulo.user_name.style.backgroundColor=""; document.modulo.usr_email.style.backgroundColor=""; document.modulo.pwd.style.backgroundColor=""; document.modulo.pwd2.style.backgroundColor=""; // 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 FULL_NAME if ((nome == "") || (nome == "undefined")) { alert("Il campo Nome è obbligatorio."); document.modulo.full_name.focus(); document.modulo.full_name.style.backgroundColor="red"; return false; }  //Effettua il controllo sul campo ADDRESS else if ((indirizzo == "") || (indirizzo == "undefined")) { alert("Il campo Indirizzo è obbligatorio."); document.modulo.address.focus(); document.modulo.address.style.backgroundColor="red"; return false; }  //Effettua il controllo sul campo COUNTRY else if ((nazione == "") || (nazione == "undefined")) { alert("Il campo Nazione è obbligatorio."); document.modulo.tel.focus(); document.modulo.tel.style.backgroundColor="red"; return false; }  //Effettua il controllo sul campo TEL else if ((telefono == "") || (telefono == "undefined")) { alert("Il campo Telefono è obbligatorio."); document.modulo.country.focus(); document.modulo.country.style.backgroundColor="red"; return false; }  else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) { alert("Inserire un indirizzo email corretto."); document.modulo.usr_email.select(); document.modulo.email.style.backgroundColor="red"; return false; } //INVIA IL MODULO else { document.modulo.action = "e_register.php "; document.modulo.submit(); } } $(document).ready(function(){ $.validator.addMethod("username", function(value, element) { return this.optional(element) || /^[a-z0-9\_]+$/i.test(value); }, "Username must contain only letters, numbers, or underscore."); $("#regForm").validate(); });  </script> 
come posso far si che si attivi la funzione in javascript che ho fatto io dopo?
ovvero come posso fare in modo che si faccia anke il controllo mio sui campi?