$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']));
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:
- 0: {command:settings, settings:{basePath:/, pathPrefix:,…}, merge:true}
- 1: {command:insert, method:null, selector:null,…}
- command: "insert"
- data: "<span style='color: red;'>The answer you entered for the CAPTCHA was not correct.<br></span>"
- method: null
- selector: null
- settings: null
- 2: {command:insert, method:prepend, selector:null,…}
- command: "insert"
- 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>↵"
- method: "prepend"
- selector: null
- settings: null
"CAPTCHA session reuse attack detected" ???
M.