Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:48:58+00:00 2026-06-13T03:48:58+00:00

can anyone help on how to verify mobile numbers in this script using Ghana

  • 0

can anyone help on how to verify mobile numbers in this script using Ghana number formats. The script validates with only Indian mobile numbers. I want to use ghana mobile numbers to validate the code.

Ghana mobile numbers start with 02 or 05. Thank u.

     pic1 = new Image(16, 16); 
pic1.src = "images/loader.gif";

/*function mobile_validation(mobile_number)
{
    var first_digit = mobile_number.charAt(0);
    var number_length = mobile_number.length;
    if(!isValid(mobile_number, 'numeric'))
        return "Please enter valid mobile number.";
    if(mobile_number.indexOf("+91") != -1 || mobile_number.indexOf("0") == 0 || number_length != 10) //ghana country code is +233
        return "Please enter valid mobile number.";
    if(first_digit != 9 && first_digit != 8 && first_digit != 7) //want to change to 02 or 05
        return "Please enter a valid mobile number.";
    if(mobile_number == "9867045061")
        return "Please enter a valid mobile number.";
    return "valid";
}*/

$(document).ready(function(){

$("#mobile").change(function() { 

var usr = $("#mobile").val();
var first_digit = usr.charAt(0);
var number_length = usr.length;

if(usr.length == 10 && !isNaN(usr) && first_digit == 9 || first_digit == 8 || first_digit == 7) // want to change to 02 or 05
{
$("#statusmb").html('<img src="images/loader.gif" align="absmiddle">&nbsp;Sending Verification Code...');

    $.ajax({  
    type: "POST",  
    url: "verify_mobile.php",  
    data: "mobile="+ usr,  
    success: function(msg){  

   $("#statusmb").ajaxComplete(function(event, request, settings){ 

    if(msg == 'OK')
    { 
        $("#mobile").removeClass('object_error'); // if necessary
        $("#mobile").addClass("object_ok");
        $(this).html('&nbsp;<img src="images/ok.png" align="absmiddle">&nbsp;Verification Code Sent to Mobile');
        document.getElementById('btnSubmit').disabled =false;
    }  
    else  
    {  
        $("#mobile").removeClass('object_ok'); // if necessary
        $("#mobile").addClass("object_error");
        $(this).html(msg);
        document.getElementById('btnSubmit').disabled =true;
    }  

   });

 } 

  }); 

}
else
    {
    $("#statusmb").html('&nbsp;<img src="images/alert.png" align="absmiddle">&nbsp;<font color="red">Please Enter <strong>Valid</strong> Mobile No.</font>');
    $("#mobile").removeClass('object_ok'); // if necessary
    $("#mobile").addClass("object_error");
    }

});

});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:48:59+00:00Added an answer on June 13, 2026 at 3:48 am

    The problem at hand is better handled using regex. The script does a terrible job of even matching the Indian number patterns.

    Also, the way it stands, it seems that the script is doing a basic validation on length and the beginning digit and then sending it to the server for further (presumably deeper) validation, as evidenced in the line

    url: "verify_mobile.php",
    

    If that is what you are doing too, then you can simply change the line

    if(usr.length == 10 && !isNaN(usr) && first_digit == 9 || first_digit == 8 || first_digit == 7) // want to change to 02 or 05
    

    to

    if(usr.length == 10 && !isNaN(usr) && first_digit == 0)
    

    assuming the length is 10 for Ghana numbers too.

    If you don’t want to stick to the script, then use the regex provided in the other answers (which I recommend).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help - this is driving me mad. I am calling a mysql
Can anyone help me with the script to refresh the page once . I
Can anyone help me to verify if a certain url ends with mp4 on
Can anyone help me trying to find out why this doesn't work. The brushes
Can Anyone help me why x2 prints zero. I guess because of floating point
Can anyone help me how to split /explode verse format to 3 parts? The
Can anyone help me to get good WordPress interview questions and answers. Any link
Can anyone help me in converting scalar type of openCV to basic types like
can anyone help me for the exercise 12.5 of Jason Hickey's book? Basically, the
Can anyone help me find an up-to-date, working ATL project which has a main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.