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

  • Home
  • SEARCH
  • 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 8087103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:40:00+00:00 2026-06-05T18:40:00+00:00

How can I allow spaces within an a numbers only validation, with a minimum

  • 0

How can I allow spaces within an a numbers only validation, with a minimum of 8 digits?
Phone numbers are much easier to type in when spaces are allowed. e.g. 0400 123 456, 9699 1234.

Here’s my code so far, I’ve only got the minimum 8 digits validation working:

jQuery.validator.addMethod(
  "phone",
  function(phone_number, element) {
    return this.optional(element) || /^\d{8}$/.test(phone_number);
  },
    "Please enter numbers only"
);
  • 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-05T18:40:02+00:00Added an answer on June 5, 2026 at 6:40 pm

    Remove the space before validating:

    return this.optional(element) || /^\d{8,}$/.test(phone_number.replace(/\s/g, ''));
    

    This way you retain the space

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

Sidebar

Related Questions

How can I allow single hyphens and single spaces only within words but not
I have a table containing cells with phone numbers. How can I allow the
I have this regex: preg_match(#^([0-9]+)$#, $post['telephone']) who allow only numbers (for a phone number
Allow letters, numbers and spaces (3 spaces maximum). How can i do it using
How can I annotate my model so I can allow only alphabets like A-Z
From this questions : javascript regex : only english letters allowed How can I
hi guys below is my regex to allow only alphabets and spaces with single
Is there a standard MBEAN of JMX that can allow me to read files
As far as I know, Drupal Services Module can allow PHP scripts to communicate
When creating a child process in C++ using Windows API, one can allow inheritance

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.