Perad Posted October 7, 2008 Share Posted October 7, 2008 Hi, I am really struggling on this. All I am looking to do is have a simple question which visitors answer. I know this will not stop bots, its not supposed to. I am just looking for something which will stop the average user from posting without thinking. This is what I have so far... <script type="text/javascript"> num1 = Math.floor(Math.random()*25); num2 = Math.floor(Math.random()*25); function checkForm(submitted) { if (num1 + num2 != submitted) { // Make element return error; return false; } } </script> <label for="anti-spam" id="anti-spam" style="float:left; padding-top:6px; margin-right:10px;"> <strong style="font-size:1.5em;"> <script type="text/javascript"> document.write(num1 + ' + ' + num2 + ' ='); </script> <noscript>1 + 1</noscript> </strong> </label> <input type="text" name="anti-spam" id="anti-spam" class="text" style="width:60px;" /> <span id="error"></span> A couple of questions really. 1) Is there a way I can hide this form from people without Javascript? 2) How do make the error show up in the span tag with the id of error. 3) Where do I put this? Do I add the function to onSubmit="" at the top of the form. Help is much appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
Perad Posted October 7, 2008 Author Share Posted October 7, 2008 Just wanted to add, I have recently had a load of users posting one word replies in the comment box. Theory is.. if they have to add up 19+24 they won't bother posting. Meanwhile if someone has something to say, doing the sum isn't a problem as the post contains enough value for it to be worth the effort. How effective it will be I will have to wait and see. I know I could put a minimum length on posts but this stops people writing what they want. I just want this Quote Link to comment Share on other sites More sharing options...
Perad Posted October 7, 2008 Author Share Posted October 7, 2008 Can't find the button but solved. Managed to hack something together and I went for an alert instead of an inline error message. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.