Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I protect phone number from bots

Tags:

jquery

php

I want a phone number which display on public page will be protected. Example converts phone number characters to HTML entities and bots can't grab the number in plain text. Let me know the trick.

like image 814
Blur Avatar asked Dec 14 '10 12:12

Blur


People also ask

Can my mobile number be used by someone else?

Mobile phone numbers can legally be ported from one provider to another when you switch your mobile phone service, and can also be ported from one mobile phone to another when you upgrade or change devices. But with enough of your personal information, scammers can have your number ported to a device they possess.

Can bots get your phone number?

You show your email address and/or phone number in your website and sooner or later that information is harvested by spam-bots, so it's important that it's not visible to them, yet, must be visible to your users.

Should you put your phone number on your website?

The aim is to make it as easy as possible for customers to contact you – so be there to provide assistance. Overall, it's a great idea for businesses to put their contact number on their website and it can even increase conversions and revenue.


2 Answers

This is a...passing thought, though I'm not sure how practical it would be:

<span class="protectedNumber" title="01234567890"></span>

css:

span.protectedNumber:before {
    content: "Phone number: " attr(title);
}

JS Fiddle demo.


Edited, in response to 'cross browser?' question in comments, to add a jQuery option to assist with those browsers that don't have the ability to deal with css-generated content:

$(document).ready(
    function(){
       $('.protectedNumber').each(
           function(){
               $(this).text('Phone number: ' + $(this).attr('title'));
           }); 
    });
like image 122
David Thomas Avatar answered Nov 01 '22 12:11

David Thomas


some ideas

  • display the phone number as an image
  • use javascript to create and display the phone number
  • throw in html tags in between the numbers (e.g. [span]) that visually makes no difference but makes it more difficult for the bot to recognize the phone number
like image 37
JohnSmith Avatar answered Nov 01 '22 11:11

JohnSmith