Avoiding form spam

I have a long quote form on my website. Lately, just in the past week, I’ve received about 5 emails from this form with nothing filled in except a big list of porn links or other obnoxiousness in the comments box. I’m running this on FormMail and do have required fields set up but apparently that’s very easy to get around.

I’m in the process of improving my JavaScript knowledge and had recently done a tutorial about form validation, so I applied that knowledge this morning.

In my quote form I inserted this into the <head> section of my php page:

I made my form name ‘form1’ and added this to the <form> tag:

onsubmit="return validate();"

I uploaded it and tested it. Now when someone fails to fill in one of the fields listed above they get a popup box and it doesn’t let them continue.

I know this might not be effective (what happens if they have popups turned off?) but it might enough to dissuade a casual form saboteur, maybe? If it continues to happen I’ll take further action and keep you posted.

Leave a Reply

Your email address will not be published. Required fields are marked *