Search code examples
formsspam-prevention

Can anyone help me out on a form spamming issue?


I have a form for enquiries on my website. Spammers are using it to keep sending me SEO and dating links. I want to stop this. They aways enter "google" in the company name field before submitting the form.

Is there an easy way to send these spammers on to my "thankyou" page on submit, so they think they have successfully spammed me but in effect nothing has happened?

Basically - if submitted companyname field = google then on submit do not send form results by email but just present thankyou.html page.

My page is here here is my contact form


Solution

  • Followup from the comments section.

    Inside your formCheck() function, replace this piece of code

    if (alertMsg.length == l_Msg){
        return true;
    }else{
        alert(alertMsg);
        return false;
    }
    

    with

    if (alertMsg.length == l_Msg){ // No alerts
        let companyName = formobj.elements['Company'].value || "";
        if(companyName.trim().toLowerCase()==='google'){ // Potential spam, redirect to "Thank you" page.
            window.location.href='confirm.htm'
            return false;
        }
        // Otherwise, proceed as valid entry.
        return true;
    }else{
        alert(alertMsg);
        return false;
    }