I would like to ask if anyone could help me about AJAX validation error message with CAPTCHA (secureimage) - At the moment the error message display at processForm.php, IF user entered a wrong code.
But what I would like do to is; the error message will POP UP on the same page on checkForm.php instead of the next page. I managed to show the error message if user did not fill the code field but not able to show the error message IF user entered the code incorrect.
Basically I have forms (checkForm.php, processForm.php & thankyou.php) - I have all the standard check error / validation which is in JavaScript e.g.
checkForm.php
PHP
<?php
session_start();
require("include/application_top.php");
?>
<script type="text/javascript">
$(document).ready(function(){
$('#btn_submit').click(function() {
var error_num = 0;
var error_mesg = "";
$('name=name').parent().removeClass('error');
if($('name=name').val()==""){
error_num++;
error_mesg += "Please enter your name\n";
..
..
..
$('name=name').parent().addClass('error');$('name=captcha_code').parent().removeClass('error');
if($('name=captcha_code').val()==""){
error_num++;
error_mesg += "Please enter the image verification\n";
$('name=captcha_code').parent().addClass('error');
}
if(error_num>0){
alert(error_mesg);
}else if(error_num==0){
//alert("in");
$('#present_form').submit();
//document.present_form.submit();
}
return false;
});
});
</script>
<!--And the rest are just HTML code-->
..
..
<tr>
<td width="20%">Name</td>
<td width="80%"><input name="name" type="text" id="name" size="30" /></td>
</tr>
..
..
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="20%"><input type="text" name="captcha_code" size="20" maxlength="6" />
Different Image </td>
<td width="80%">
</tr>
</table>
[/PHP]
processForm.php
PHP
<?php
session_start();
require("include/application_top.php");
include_once $_SERVER . '/securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST) == false) {
//echo "The security code entered was incorrect.
";
echo "The code you entered was incorrect. Please go back and try again. ";
exit;
}
<!--The rest of the code are just connection to DB-->
[/PHP]
Can anyone assist me on this please? Thanks in advance.