- PHP Tutorial
- 430 comments
Protect email address from spam bots
- Tuesday, 6th December, 2011
- Javascript Tutorials
- 9 Comments
Protecting your email addresses from spam bots is the thing that you should do after making your web forms using the CAPTCHA verification script. You probably know that spam bots are used to visit your web site pages and extract all email address that can be found there. Usually a regular expression is used to match all email address. Using a simple JavaScript function you can make your email address "invisible" to spam bots but still visible for your web site visitors. I've created a JavaScript function that takes 4 parameters and builds a clickable email link.
Now, assume that your email address is [email protected]. When you want to have a clickable email on your web pages you use this:
However, the email address is listed as a plain text and every spam bot can easily find it out. Using the above JavaScript function you can still have a clickable email address on your web page but spam bots will not be able to find it out. All you need to use is:
The emailantispam() function will build an email address using the 4 parameters you pass to it.
<script language="javascript">
function emailantispam(email1, email2, email3, email4){
emailE = email1 + email2 + '@' + email3 + email4;
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
};
</script>
Now, assume that your email address is [email protected]. When you want to have a clickable email on your web pages you use this:
<a href="mailto:[email protected]">[email protected]</a>
However, the email address is listed as a plain text and every spam bot can easily find it out. Using the above JavaScript function you can still have a clickable email address on your web page but spam bots will not be able to find it out. All you need to use is:
<script language="javascript">emailantispam('tom','rogers','yah','oo.com');</script>
The emailantispam() function will build an email address using the 4 parameters you pass to it.