Ciao a tutti,
è da una settimana che mi sbatto per far funzionare una validazione form che ho creato utilizzando ajax...(è la mia prima prova con ajax)...
ho fatto funzionare tutto...tranne che per l'ultimo controllo...cioè che l'utente abbia dato l'autorizzazione al trattamento dei dati personali...(checkbox)...questa infatti non viene mai presa in considerazione per il controllo...(quando clicco su invia)...mentre se scateno il controllo all'evento onChange della check allora questa funziona...
non so + dove sbattere la testa...
posto i codici e spero che qualcuno mi dia na mano...

index.php(il form)
Codice PHP:
<?php



$data 
= array('nome'=>'''cognome'=>'''sesso'=>'''telefono'=>'''citta'=>'''data_nascita'=>'''email'=>'''email2'=>'','username'=>'''password'=>'''password2'=>'''autorizzazione'=>'');

$errors null;

$class 'error';

$msg '';

if(
$_SERVER['REQUEST_METHOD'] == 'POST') {

    require 
dirname(__FILE__) . '/' 'user.php';
    
$datiForm = array();
    

    

    foreach( 
$_POST as $chiave => $valore){
        
$datiForm[$chiave] = $valore;
    }
    
$datiForm['autorizzazione'] = $_POST['autorizzazione'] ;
    
    foreach( 
$datiForm as $chiave => $valore){
        echo 
$chiave.": ".$valore;
        echo 
"
"
;
    }
    
$u = new User($datiForm);
    
    if(isset(
$u)){

        if(
$u->validate()) {
            

            if(
$u->store()) {

                
$class 'success';

                
$msg 'Registrazione effettuata';

            }

        }
    }

    
$errors $u->getErrors();

    if(isset(
$errors['info'])) {

        
$msg $errors['info'];

        
$class 'error';

    }

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <title>AJAX: Validazione di un form</title>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <link href="main.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript" src="validate.js"></script>

    </head>

    <body>


        <fieldset>

            <legend>Registrazione Nuovo Utente</legend>



            <div class="<?php echo $class?>" id="info_msg"><?php echo $msg?></div>

        <form name="frmReg" method="post" action="index.php" onsubmit="if(nosubmit) {return false;}">
        
        <table width="100%" border="1">
            
            
            <tr>
                <td id="label_form">
                    <label for="nome">Nome:</label>

                </td>
                <td id="input_form">
                    <input id="nome" name="nome" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('nome'); }?>" >

                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="nome_msg">

                        <?php if(isset($errors['nome'])) {echo $errors['nome'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="cognome">Cognome:</label>

                </td>
                <td id="input_form">
                    <input id="cognome" name="cognome" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('cognome'); }?>" >

                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="cognome_msg">

                        <?php if(isset($errors['cognome'])) {echo $errors['cognome'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="sesso">Sesso:</label>

                </td>
                <td id="input_form">
                    <select name="sesso" id="sesso" onblur="validate(this.id, this.value)">
                    <?php
                    
if(isset($u) && $u->get("sesso") != ""){

                    
?><option value="<?php echo $u->get("sesso"); ?>" selected = "selected"><?php echo $u->get("sesso"); ?></option>
                        <?php if($u->get("sesso") != "M"){ ?><option value="M">M</option><?php ?>
                        <?php if($u->get("sesso") != "F"){ ?><option value="F">F</option><?php ?>
                    <?php }else{ ?>
                        <option value=""  selected = "selected"></option>
                        <option value="M">M</option>
                        <option value="F">F</option>
                    <?php ?>
                </select>                
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="sesso_msg">

                        <?php if(isset($errors['sesso'])) {echo $errors['sesso'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="telefono">Telefono:</label>

                </td>
                <td id="input_form">
                    <input id="telefono" name="telefono" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('telefono'); }?>" />

            
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="telefono_msg">

                        <?php if(isset($errors['telefono'])) {echo $errors['telefono'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            

            
            <tr>
                <td id="label_form">
                    <label for="citta">Citt&agrave;:</label>

                </td>
                <td id="input_form">
                    <select name="citta" id="citta" onblur="validate(this.id, this.value)">
                        <?php include('js/carica_citta/select_citta.php'); ?>
                    </select>
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="citta_msg">

                        <?php if(isset($errors['citta'])) {echo $errors['citta'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
                
            
            <tr>
                <td id="label_form">
                    <label for="data_nascita">Data di nascita:</label>

                </td>
                <td id="input_form">
                    <input id="data_nascita" name="data_nascita" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('data_nascita'); }?>" />

                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="data_nascita_msg">

                        <?php if(isset($errors['data_nascita'])) {echo $errors['data_nascita'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            

            
            
            <tr>
                <td id="label_form">
                    <label for="email">Email:</label>

                </td>
                <td id="input_form">
                    <input id="email" name="email" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('email'); }?>" >
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="email_msg">

                        <?php if(isset($errors['email'])) {echo $errors['email'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="email2">Ripeti email:</label>

                </td>
                <td id="input_form">
                    <input id="email2" name="email2" type="text" onblur="validateSecondMail(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('email2'); }?>" >
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="email2_msg">

                        <?php if(isset($errors['email2'])) {echo $errors['email2'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="username">Username:</label>

                </td>
                <td id="input_form">
                    <input id="username" name="username" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('username'); }?>" >

                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="username_msg">

                        <?php if(isset($errors['username'])) {echo $errors['username'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="password">Password:</label>

                </td>
                <td id="input_form">
                    <input id="password" name="password" type="text" onblur="validate(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('password'); }?>"  align="right">
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="password_msg">

                        <?php if(isset($errors['password'])) {echo $errors['password'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
            
            
            <tr>
                <td id="label_form">
                    <label for="password2">Ripeti password:</label>
                </td>
                <td id="input_form">

                    <input id="password2" name="password2" type="text" onblur="validateSecondPassword(this.id, this.value)" value="<?php if(isset($u)) { echo $u->get('password2'); }?>" >
                </td>
                <td id="img_form">
                    [img]img/ajax-loader.gif[/img][img]img/checked.gif[/img]

                </td>
            </tr>
            <tr>
                <td id="label_form"></td>
                <td id="input_form">
                    <span class="error" id="password2_msg">

                        <?php if(isset($errors['password2'])) {echo $errors['password2'];}?>

                    </span>
                </td>
                <td id="img_form"></td>
            </tr>
        </table>
            
            
            <input id="autorizzazione" name="autorizzazione" value ="auth" type="checkbox" onMouseUp="validate(this.id, this.checked)">
            [img]img/ajax-loader.gif[/img]
            [img]img/checked.gif[/img]
        Autorizzo il trattamento dei dati personali ai sensi della L. 196/03
        


                    <span class="error" id="autorizzazione_msg">

                        <?php if(isset($errors['autorizzazione'])) {echo $errors['autorizzazione'];}?>

                    </span>

        <hr>



        <input type="submit" name="submit" value="Invia" class="button" />

        </form>

        </fieldset>



    </body>

</html>