I'm getting a lot of spam om my websites where I have a couple of email/contact forms.

The forms are all validated/submitted inline with jQuery/ajax.

However, spam bots skip javascript so I want to validate the form natively too.

I don't want to use a (hidden) CAPTCHA.

EE/CI can validate emails and numbers etc. But I have a phone number field for example and I don't want to force users to use a specific pattern 000-000-000 etc. I just want to allow only 0-9 spaces and dashes and (). At the moment spam bots put anything there.

Also, I have a name field which spam bots use to put email addresses in. So I would like to disallow the @ sign and other symbols that no one uses in their name.

Also I don't want to even accept html tags or common spam strings like "

How would I do this without javascript?

2 Answers 2


You couldn't have such validations via the freeform tags. You will need to develop an extension with the hook freeform_module_validate_begin. Within the hooked function you can validate the user inputs and prepare the $error array.

You can take a reference from here: http://www.solspace.com/docs/freeform/extension_hooks/#freeform_module_validate_begin


Freeform 4 allows specifying different types of text inputs, including numbers, when creating text fields: http://www.solspace.com/docs/freeform/default_fieldtypes/#text_field_content_type

Input failing the requirements will be validated negative.

  • Thanks, however, a phone number is not just a number so this won't work.
    – JonkBok
    Aug 12, 2013 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.