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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:56:37+00:00 2026-06-07T14:56:37+00:00

I have set up validation for a HTML form using jQuery and I’m looking

  • 0

I have set up validation for a HTML form using jQuery and I’m looking for some help regarding the phone number validationy, I have been searching online and here’s what I came up with but its still not working! I have the email and name inputs validating but cant figure out how to implement the phone number validation correctly as its still accepting letters when I submit? I need the input to only accept a maximum of 15 numbers and also accept the + sign at the start if neccessary?

The regEx I used is: /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/ and I’m aware this isn’t correct but I cant even get this to work?

Any input on how to fix this problem much appreciated!

$('#submit_second').click(function(){
    //remove classes
    $('#second_step input').removeClass('error').removeClass('valid');

    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var phonePattern = /^[0-9]{3}\-[0-9]{7}$/ ;  
    var fields = $('#second_step input[type=text]');
    var error = 0;
    fields.each(function(){
        var value = $(this).val();
        if( value.length<1 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) )  ) {
            $(this).addClass('error');
            $(this).effect("shake", { times:3 }, 50);

            error++;
        } else {
            $(this).addClass('valid');
        }
    if( value.length<1 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='phone' && !phonePattern.test(value) )  ) {
            $(this).addClass('error');
            $(this).effect("shake", { times:3 }, 50);

            error++;
        } else {
            $(this).addClass('valid');
        }


 });
  • 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-07T14:56:39+00:00Added an answer on June 7, 2026 at 2:56 pm

    This should do it:

    /^\+?[0-9]{0,15}$/
    

    This matches up to 15 numbers, optionally prefixed with +

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

Sidebar

Related Questions

I have set up jQuery validation on a page using jQuery 1.7.1 as follows.
I am using jquery validation plugin for clientside validation of a form. I have
i have a jquery form validation in the master page and it works fine
I am using jquery validation 1.9.0. I have used the latest Jquery and on
I'm getting more into jQuery and so have set up a HTML/Javascript/CSS base site
We have HTML form which will allow french alphabets. So we have added validation
I have to build a registration form using asp.net mvc 3 jquery validate. That
I have an issue using an object property as jquery selector define([models/security/user, 'text!templates/security/registration.html'], function(SecurityUserModel,
Something strange is happening here. I have a basic form: <% using (Html.BeginForm()) {
I have set validation attributes in the model of my WCF service [MinLength(6, ErrorMessage

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.