I have a "contact us" form that uses Ajax (i.e. relies on asynchronous requests).
In case the user has javascript disabled, I want to display a message, saying something like:
You need to enable Javascript to use this contact form. If you can't, or don't know what Javascript is, then use your email and contact us at
<the_email_address>
.
But of course, I want to hide the_email_address
from spambots.
Since this email address has to be displayed inside a <noscript>
, it makes no sense to scramble it with Javascript, specially given the fact that some users may simply not even know what Javascript is.
I thought of a solution but I have no way to test it: Inserting empty <span></span>
tags, as in
my_em<span></span>ail@g<span></span>mail.com
Or, a bit cleverer
my_em<span style="display:none">garbage</span>ail@gmail.com
Would that work? If not, any better ideas?
Update
Thanks RichieHindle for the ansewr. I thought I'd share a simple implementation of the idea in python:
def html_nospam(string):
def ent(char):
return "&#%d;" % ord(char)
return ''.join([ent(c) for c in string])