Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6639617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:34:30+00:00 2026-05-25T23:34:30+00:00

I have a form which uses ajax for data submitting. Here is the html:

  • 0

I have a form which uses ajax for data submitting. Here is the html:

<form>
    <input type="text" id="content" name="content">
    <input type="submit" class="button" name="button">
</form>    

and the JavaScript (jQuery):

$(function() {
    //Update Message...
    $(".button").click(function() {
        var boxval = $("#content").val();
        var dataString = 'content='+ boxval;

        if(boxval=='')
        {
            alert("Please Enter Some Text");
        }
        else
        {
            $("#flash").show();
            $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>');

            $.ajax({
                type: "POST",
                url: "update_data.php",
                data: dataString,
                cache: false,
                success: function(html){
                    $("ol#update").prepend(html);
                    $("ol#update li:first").slideDown("slow");
                    document.getElementById('content').value='';
                    document.getElementById('content').focus();
                    $("#flash").hide();
                }
            });
        } 
        return false;
    });
});

It is all working fine, but there is a big problem: I cannot stop spam.
Last time I used spam filters, it was in PHP (I used a hidden input and then checked in the PHP file if it is filled out). But that was totally in PHP, no JS.

So here is my question:
How could I stop spam in this form submission? Also, can I create an if statement in the update_data.php file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:34:31+00:00Added an answer on May 25, 2026 at 11:34 pm

    I you do not like to add Captcha here is a good solution:

    First add input that is hidden with css in the form. If the bot submits the form the hidden field will have some value filled by the bot. In normal cases the human will not see it and will be empty. In the case of a bot you will check it and if it has some value you will discard.
    Also you need to add input (also hidden with css) with javascript on document ready. If it is browser it will execute the javascript and will insert the input in the form. If it is a bot then the bots do not execute js and there will be no input field generated by js and on the server side you will see that there is no such field and you will discard the request.

    So on the server side you will check if the first hidden field has value or the second hidden field does not exist discard the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form, in which I need to send data selected via AJAX
I have this login form which uses AJAX to query a database for checking
I have a basic login form, which uses ajax to login users. If the
I have a php script which uses the following line to submit a form
I have the following form for photo_album which uses the nested forms feature of
I have a form which users must fill out and submit. The controller action
I'm writing a PHP application which uses AJAX to submit forms via POST when
Hi I have a field that uses ajax to bring up product/item information <input
I'm using the jQuery validation plugin and the form uses ajax to submit the
I have a simple contact form which uses jquery to post to a php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.