Combine jQuery Form Validation Plugin + basic captcha scheme?
Hello
I'd like to use a simple JavaScript anti-spam scheme and found
this one that requires the user to add two numbers.
Problem is, I'm no JavaScript expert and don't know how to have the jQuery plug-in go on validating the form once the user has answered the math question successfully:
- <html>
- <head>
- <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("Résultat de "+ 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>
-
- <script>
- //Used by jQuery to validate all form fields
- $(document).ready(function(){
- $("#myform").validate();
- </script>
- </head>
- <body>
- <form action="send.php" method="post" id="myform">
- <input type="text" maxlength="25" id="name" name="name" class="required"/>
- Are you human?<br />
- <script type="text/javascript">DrawBotBoot()</script>
- <input id="Button1" type="button" value="Send" onclick="alert(ValidBotBoot());"/>
- </form>
- </body>
- </html>
Would someone know?
Thank you.