[eluser]Unknown[/eluser]
Hello,
I'm trying to insert a reCAPTCHA code into my login form and everything went pretty well.
But since the form is sent trough an ajax $.(post) command, if the form_validation->run() fails the page is reloaded.
if the form is reloaded, it seems that reCAPTCHA can't be reloaded into the form and I can't figure out why.
here is the view code:
Code:
[removed][removed]
[removed]
$(function() {
$( "#submit" ).button();
});
function showRecaptcha(element) {
Recaptcha.create("6LcjCMYSAAAAAB7KIMKe3m4JyWse3xS8p74Ri50O", element, {
theme: "red",
callback: Recaptcha.focus_response_field});
}
$(document).ready(function(){
showRecaptcha('recaptcha_div');
$("#loading").hide();
$("#loginform").submit(function(e)
{
e.preventDefault();
$("#loading").slideDown('fast');
$("#formcontainer").slideUp();
$.post("<?=base_url();?>aziende/login", $("#loginform").serialize(),function(data){
$("#formcontainer").html(data).slideDown('slow');
$("#loading").hide();
});
})
});
[removed]
<?php if(!$submitted) { ?>
<div id="loading" align="center"><img src="<?=base_url();?>images/loading.gif" /></div>
<div id="formcontainer">
<?php } ?>
<div align="center" id="formError"><?php echo validation_errors(); ?></div><br />
<form method="post" action="" id="loginform">
<table border="0" width="100%">
<tr><td align="right" width="50%">
<label for="email">Email:</label></td>
<td align="left"><input type="text" name="email" placeholder="Il tuo indirizzo email" value="<?=$email;?>" /></td>
</tr>
<tr><td align="right">
<label for="password">Password:</label></td>
<td align="left"><input type="password" name="password" value="<?=$password;?>" /><br />
</td></tr>
<tr><td colspan="2" align="center"><div id="recaptcha_div"></div></td></tr>
<tr><td colspan="2" align="center"><input type="hidden" name="go" value="1" /><br />
<input type="submit" value="Registrati!" id="submit" /></td>
</tr>
</table>
</form>
<?php if(!$submitted) { ?></div><?php } ?>
I tried loading reCAPTCHA without the javascript command (trough iframe) but the problem seems to persist.
this is the view that is reloaded with ajax on form error.
when I say that reCAPTCHA is not reloaded I mean that the whole reCAPTCHA box is not showing up...
ty for help
P.S.
- sometimes it works without any code change...
- if I submit the right word the login is successfull, so there is no controller error on form_validation
- the first "removed" items on my code are the script for google reCAPTCHA api