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('BotBootInput').value;
        if (d == c) return true;        
        return false;    
    }
    </script>
</head>
<body>
Are you human?<br />
<script type="text/javascript">DrawBotBoot()</script>
<input id="Button1" type="button" value="Check" onclick="alert(ValidBotBoot());"/>

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.
GDB08Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StealthyDevCommented:
Does the code attached helps you?

<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('BotBootInput').value;
        if (d == c) return true;        
        return false;    
    }
    </script>
</head>
<body>
<form action="captcha-submitpage.html">
	Are you human?<br />
	<script type="text/javascript">DrawBotBoot()</script>
	<input value="Send" type="submit" name="submit1" onclick="return ValidBotBoot();"/>
</form>

Open in new window

StealthyDevCommented:
The secret is:

If you return false to submit button, the form will not be submitted !

Cheers.
GDB08Author Commented:
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?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

StealthyDevCommented:
LOL !

Rookie to JavaScripting? Its as simple as this:

All the best.


<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('BotBootInput').value;
        if (d == c) return true;        
		alert("This is wrong, please try again.");
        return false;    
    }
    </script>
</head>
<body>
<form action="captcha-submitpage.html">
	Are you human?<br />
	<script type="text/javascript">DrawBotBoot()</script>
	<input value="Send" type="submit" name="submit1" onclick="return ValidBotBoot();"/>
</form>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GDB08Author Commented:
Thanks :-)
StealthyDevCommented:
:) 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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.