Locate Mobile Number Using JavaScript in ASP.Net


This article describes how to locate a mobile number in India in ASP.Net using JavaScript with state, service provider and service type.


To create this application you need a JavaScript file that contains nearly all the mobile number data.

  • MoLocater.js
You can download it from the source code attached to this page.


Add a textbox, a button and three div tags.

Now design your screen as in the following screen.


Or you can copy the following source code:

<form id="form1" runat="server">
                    Mobile No. Locater
                    <asp:TextBox ID="txtMobileNo" runat="server" MaxLength="10"></asp:TextBox>
                    <asp:Button ID="Button1" runat="server" Text="Trace" OnClientClick="return GetPhnlocation();" />
                <td colspan="3">
                    <div align="center" id="name" style="font-weight: bold;">
                    <div align="center" id="company" style="font-weight: bold;">
                    <div align="center" id="idno" style="font-weight: bold;">
                    <div align="center" id="info" style="font-weight: bold;">

Next add the MoLocater.js JavaScript file to your website and add the link to the head tag:

<script src="MoLocater.js" type="text/javascript"></script>

In the MoLocater.js file is the fuction
GetPhnlocation(); see it to get the details.

I catch the first 4 digits of the Mobile number and match it to the 4 digit mobile pattern. Sample code is given below.

function GetPhnlocation() {

var phone = document.getElementById('txtMobileNo');

var number = document.getElementById('name');
var state=document.getElementById('company');
var provider=document.getElementById('idno');
var service=document.getElementById('info');
var code = phone.value.slice(0, 4);
var re = /^[0-9]+$/;
if (phone.value != '' && re.test(phone.value)&& (phone.value.length==10) ) {
  if (code == "9000") {
      number.firstChild.nodeValue = 'Mobile No: ' + phone.value;
      state.firstChild.nodeValue = 'State: Andhra Pradesh';
      provider.firstChild.nodeValue = 'Service Provider: Airtel';
      service.firstChild.nodeValue = 'Service Type: GSM';

      return false;


According to this you can also add your new pattern to this code.

Now build your application and enter a mobile number then click on the trace button. It will show all details of that mobile number.

For any modifications or problems please comment.



Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now