I’m using this script to validate my php form.
<script>
function validate()
{
dm = document.contact;
if(dm.elements["name"].value == "")
{
alert ("Please Enter Your Full Name");
return false;
}
if(dm.elements["comments"].value == "")
{
alert ("Please Enter Your Comments");
return false;
}
if(dm.elements["email"].value == "")
{
alert ("Please Enter Your Email");
return false;
}
var str = dm.elements["email"].value;
var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
if (!reg1.test(str) && reg2.test(str)){ // if syntax is valid
return 1;//return true;
}else{
alert ("Invalid Email entered");
return false;
}
}
</script>
I would like to add another input for security.
It would be something like:
“Please type the word ‘puppy’ into the space below:
____________”
Then the script could check to see if the word “puppy” was typed into the input. If not, it would have a pop up saying “Please type ‘puppy’ into the appropriate space”… or something like that.
I’ve tried searching… but i dont know what that would be called. Any ideas on how I could implement that?