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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:21:53+00:00 2026-05-29T16:21:53+00:00

I have setup jQuery validation on form, The validation currently tests that the telephone

  • 0

I have setup jQuery validation on form, The validation currently tests that the telephone number field isn’t empty and is a number, but I’d like it to be able to handle a user placing a space after the mobile/area code.

Can anyone advise what i’d need to do to allow this?

This is my current code –

if((phone.length == 0) || (names == 'Please Enter Your Contact Number (no space)')){  
        var error = true;  
        $('.error').fadeIn(500);  
        $('.pStar').fadeIn(500);

    }else{  
        var value = $('#phone').val().replace(/^\s\s*/, '').replace(/\s\s*$/, '');
        var intRegex = /^\d+$/;
        if(!intRegex.test(value)) {
             var error = true;  
             $('.error').fadeIn(500);  
            $('.pStar').fadeIn(500);

        } else{
        $('.pStar').fadeOut(500);
        }
    }   
  • 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-05-29T16:21:54+00:00Added an answer on May 29, 2026 at 4:21 pm

    I would highly recommend using jQuery validate rather than re-inventing the wheel

    a quick google search for uk numbers with jquery validate turned this up

    filters

    that looks like this

    jQuery.validator.addMethod('phoneUK', function(phone_number, element) {
      return this.optional(element) || phone_number.length > 9 &&
      phone_number.match(/^(\(?(0|\+44)[1-9]{1}\d{1,4}?\)?\s?\d{3,4}\s?\d{3,4})$/);
      }, 'Please specify a valid phone number'
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use jQuery to setup a form validation, but theres this
I have a setup with a traditional form that's checked with jQuery Tools validator
I have a MVC app and using JQuery. I have anchor that I setup
I have a method set up that uses jquery form for a file upload
I am using the jQuery Validation plugin and have an issue validating items that
I have a jquery template setup like this: <script id='tmpl-video_list' type='text/x-jquery-tmpl'> <li> <a href='${url}'><br/>
I have setup a simple example to show a form inside a jquery UI
jQuery Validation plugin is used to validate all form data: http://docs.jquery.com/Plugins/Validation Have 3 select
I have a generic jQuery validation call in a global JS file: $('form').each(function() {
I have some onchange events setup in jQuery which are used to populate a

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.