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 8788179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:06:01+00:00 2026-06-13T22:06:01+00:00

I am specifically targeting numerical only, So if I am using a phone mask

  • 0

I am specifically targeting numerical only, So if I am using a phone mask using javascript on front end that filters user input to (000)000-000, basically [2-9] and [0-9] as mask (jquery.maskedinput-1.3.js) and mobile filter…

jQuery(function ($e) {
var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/);
$e('#refer').val(window.location.href);

if (!(isMobile)) {      
    $e('#phone').mask('(299)299-9999');
    $e('#field_phone_number').mask('299-299-9999');
}
}); 

For server side I have a regular expression in PHP as (nothing special yet)

function phonenumber($value)
{
    return preg_match("/\(?\b[(. ]?[0-9]{3}\)?[). ]?[0-9]{3}[-. ]?[0-9]{4}\b/i", $value);
} 

How can a create a regex or php script that targets all numerical values without creating a very long regex for each character? I just want to know if someone types in (222)222-2222, they get a false on the return.

  • 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-13T22:06:02+00:00Added an answer on June 13, 2026 at 10:06 pm
    function phonenumber($value)
    {
        $prefix = '\d{3}'; // You might want to specify '2\d\d' (200 to 299)
        $regex = '#^(\('.$prefix.'\)|'.$prefix.')[\s\.-]?\d{3}[\.-]?\d{4}$#';
        if (preg_match($regex, $value))
        {
            // Number is in a suitable format
    
            // Now extract digits -- remove this section to not test repeated pattern
            $digits = preg_replace('#[^\d]+#', '', $value);
    
            // All numbers equal are rejected
            if (preg_match('#^(\d)\1{9}$#', $digits))
                return false;
            // end of pattern check
    
            // Otherwise it is accepted
            return true;
        }
        return false; // Not in a recognized format
    }
    

    This will accept (299)423-1234 and 277-111-2222, and also (400)1234567 or 4001234567. It will reject (400-1234567 and 400-12-34-56-7. It will also reject (222)222-2222 because of the repeated 2’s.

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

Sidebar

Related Questions

I'm building one of my first web apps using HTML5, specifically targeting iPhones. Since
Possible Duplicate: Targeting only Firefox with CSS I need to target firefox specifically because
Specifically: Is it assured somehow that all versions of glibc 2.x are binary compatible?
Specifically how can I: Show a button which will let the user browse through
Specifically curious if IIS 5.1 has a 64 bit version, but I'm guessing only
I'm trying to use a CSS media query, specifically targeting the iPhone. It works
What are common practices for designing a build system/project structure that allows targeting multiple
What's the best way to play sounds without flash in IE7+? I'm specifically targeting
Specifically, I think anything done with NotificationCompat can be done using the default API
specifically this question is for iPhone only, basically the question is - does iOS

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.