Exactly, just copy and paste this:
Code JavaScript
:
function validateForm(){
var errorMessage="";
var name=document.forms["contact"]["txtName"].value;
var email=document.forms["contact"]["txtEmail"].value;
var input=document.forms["contact"]["txtInput"].value;
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
if (name==null || name==""){
errorMessage = "Your Name is required.\n";
}
if (email==null || email==""){
errorMessage += "Email address is required.\n";
} else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length){
errorMessage += "Please enter a valid email address.\n";
}
if (input==null || input==""){
errorMessage += "Captcha code is required.\n";
}
if (errorMessage !=""){
alert(errorMessage);
return false;
}
}
Excellent, that worked, thanks very much.
One other thing remains to fix, the catchpa code submits even if the wrong code is submitted, I have copy and pasted the following PHP code form the original page on which I have the catchpa code into the contact page head section , but it's not working, any chance you would be able to help with this, or is it better to post this in another section of the forums?
PHP
Code:
<?php
if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['txtInput']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= "The captcha code does not match";
}
?>
Bookmarks