Hi all. I have a custom form, and I need to send it via ajax. I know that exist ['#ajax'] so  this is my form:

$form = array();
$form['name'] = array(
'#type'=> 'textfield',
'#size' => 30,
'#title'=> 'Nome',
'#weight' => "float up"

);
$form['email'] = array(
'#type'=> 'textfield',
'#size' => 30,
'#title'=> 'Email',
);
$form['phone'] = array(
'#type'=> 'textfield',
'#size' => 30,
'#title'=> 'Telefono',
);
$form['msg'] = array(
'#type'=> 'textarea',
'#size' => 30,
'#rows' => 3,
'#title'=> 'msg',
);
$form['my_captcha_element'] = array(
   '#type' => 'captcha',
   '#captcha_type' => 'captcha/Math',
);
  
$form['invia'] = array(
'#type'=> 'submit',
'#value' => 'Invia',
'#weight' => 40,
'#ajax' => array(
'callback' => 'xblock_form_contatto_ad_form_submit',
'wrapper' => 'form_submit',
),
);
$form['markup'] = array(
'#prefix' => '<div id="form_submit">',
'#suffix' => '</div>',
'#markup' => '',
);

This is my callback function: 
function xblock_form_contatto_ad_form_submit($form, $fs) {
  $errors = form_get_errors();
    if ($errors) {
    $out ="<span style='color: red;'>";
   foreach ($errors as $k => $v) {
   $out .= $v."<br>";
   }
   $out .="</span>";
   return $out;
    }

  $body = theme('xblock_form_contatto_ad_form',array('data' => $fs['values']));
  mail("michel@ziobuddalabs.it","Contatto da form",$body);
  return "<span style='color: green;'>Invio effettuato</span>";
}

My problem is the form validation: I have a captcha and I do not insert nothing so captcha validate return an error, and I can see it in the json "command" result, but when I reinsert the captcha with correct "entry" I get this:

    1. 0{command:settings, settings:{basePath:/, pathPrefix:,…}, merge:true}
    2. 1{command:insert, method:null, selector:null,…}
      1. command"insert"
      2. data"<span style='color: red;'>The answer you entered for the CAPTCHA was not correct.<br></span>"
      3. methodnull
      4. selectornull
      5. settingsnull
    3. 2{command:insert, method:prepend, selector:null,…}
      1. command"insert"
      2. data"<div class="messages error">↵<h2 class="element-invisible">Error message</h2>↵ <ul>↵ <li>CAPTCHA session reuse attack detected.</li>↵ <li>The answer you entered for the CAPTCHA was not correct.</li>↵ </ul>↵</div>↵"
      3. method"prepend"
      4. selectornull
      5. settingsnull


"CAPTCHA session reuse attack detected" ???


M.
--
Michel 'ZioBudda' Morelli                       michel@ziobuddalabs.it
Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax)
0200619074 - 3939890025 (mobile)--  Fax: +39-0291390660
http://www.ziobuddalabs.it                      Skype: zio_budda