Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Javascript phone validation

Posted on by Microsoft Employee

Hi There,

I am trying this codeto put +1 as optional and than 10 digit ph number validation on page.

I first used this code:  var phoneno =/^\d{10}$/;  which worked fine.

But now I want to modify it to accept +1 which should be optional. I am trying to  +1?  for it to be optional but not getting it through.

Can someone help

*This post is locked for comments

  • Verified answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Javascript phone validation

    Hi

    Please try the following

    ^([\+][1])?\d{10}$

    You could test this on this site with all  the different numbers and once you are happy with the regex, you can use it in your code

    ScreenClip-_5B00_605_5D00_.png

    [View:https://regex101.com/:750:50]

  • Saad Kabarousse Profile Picture
    Saad Kabarousse 732 on at
    RE: Javascript phone validation

    Hi,

    You can  try  /^\+1(?:)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans