GDB08
asked on
Simple javascript CAPTCHA verification code
I have a simple CAPTCHA verification code that looks like this:
<script type="text/javascript">
var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);
var c = a + b
function DrawBotBoot()
{
document.write("What is "+ a + " + " + b +"? ");
document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>");
}
function ValidBotBoot(){
var d = document.getElementById('B otBootInpu t').value;
if (d == c) return true;
return false;
}
</script>
</head>
<body>
Are you human?<br />
<script type="text/javascript">Dra wBotBoot() </script>
<input id="Button1" type="button" value="Check" onclick="alert(ValidBotBoo t());"/>
I need to combine it to my form so It makes the check and then if true sends the result from the form.
The value of the send button is now like this:
<input value="Send" type="submit" name="submit1" />
How can I change it so it uses the CAPTCHA verification code and then sends the form if true?
Thanks.
<script type="text/javascript">
var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);
var c = a + b
function DrawBotBoot()
{
document.write("What is "+ a + " + " + b +"? ");
document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>");
}
function ValidBotBoot(){
var d = document.getElementById('B
if (d == c) return true;
return false;
}
</script>
</head>
<body>
Are you human?<br />
<script type="text/javascript">Dra
<input id="Button1" type="button" value="Check" onclick="alert(ValidBotBoo
I need to combine it to my form so It makes the check and then if true sends the result from the form.
The value of the send button is now like this:
<input value="Send" type="submit" name="submit1" />
How can I change it so it uses the CAPTCHA verification code and then sends the form if true?
Thanks.
The secret is:
If you return false to submit button, the form will not be submitted !
Cheers.
If you return false to submit button, the form will not be submitted !
Cheers.
ASKER
Thanks a lot, this works :-)
Would it be complicated to add an alert if people add the wrong sum?
Like: This is wrong, please try again?
Would it be complicated to add an alert if people add the wrong sum?
Like: This is wrong, please try again?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks :-)
:) thanks for your points..
If you are new to JavaScripts and want to learn the beginnings, try the below link.
http://www.w3schools.com/js/js_intro.asp
Best Regards.
PS: forgive if its offensive
If you are new to JavaScripts and want to learn the beginnings, try the below link.
http://www.w3schools.com/js/js_intro.asp
Best Regards.
PS: forgive if its offensive
Open in new window