web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Help! Phone/Cellphone Number Validation on JavaScript

(0) ShareShare
ReportReport
Posted on by

Hello everyone,
What I need is an input where an user from anywhere in the world can put his Phone/Cellphone number and check if it's valid, having in count the country region and the area code.
It's supose to look something like this:
“+ (County Region) (Area Code) (Phone/Cellphone Number)"

In addition It would be great that if for example the user types +54 automaticly detects that +54 is from Argentina.

Or, Im thinking in a display that dropsdown every country with his Country Region.

Kinda like this.

Captureasd.PNG

(The phone/cellphone number must contain digits from 0 to 0, -, spaces,dots and parenthesis)

All I have Is this, that it doensn't validate:

884010802.Capture.PNG

Thank you,

Joaquín.

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hello everyone,
    What I need is an input where an user from anywhere in the world can put his Phone/Cellphone number and check if it's valid, having in count the country region and the area code.
    It's supose to look something like this:
    “+ (Country Region) (Area Code) (Phone/Cellphone Number)"

    In addition It would be great that if for example the user types +54 automaticly detects that +54 is from Argentina.

    Or, Im thinking in a display that dropsdown every country with his Country Region.

    Kinda like this.

    5415.Untitled.png

    All I have Is this, that it doensn't validate:

    373047.Capture.PNG

    Thank you,

    Joaquín.

  • necsa Profile Picture
    3,455 on at

    Hi,

    Please modified following Javascript for your request.

    function commonEventHandler(executionContext){

    var formContext=executionContext.getFormContext():

    var telephoneAttr=formContext.data.entity.attributes.getByName('telephone1');

    var isNumberWithCountryCode=telephoneAttr.getValue().substring(0,1) === '+';

    //telephone field will be a from control if invoked from a form onChange event

    //telephone field will be editable grid Gridcell object if invoked from editable grid OnChange event

    var telephoneField=telephoneAttr.controls.getByIndex(0);

    if(!isNumberWithCountryCode){

    telephoneField.setNotification('Please include the country code beginning with '+'.','countryCodeNotification');

    }

    else{

    telephoneField.clearNotification('countryCodeNotification');

    }

    }

    function commonEventHandler(executionContext) {

       var formContext = executionContext.getFormContext();    

       var telephoneAttr = formContext.data.entity.attributes.getByName('telephone1');

       var isNumberWithCountryCode = telephoneAttr.getValue().substring(0,1) === '+';

       // telephoneField will be a form control if invoked from a form OnChange event;

       // telephoneField will be a editable grid GridCell object if invoked from editable grid OnChange event.

       var telephoneField = telephoneAttr.controls.getByIndex(0);

       if (!isNumberWithCountryCode) {

           telephoneField.setNotification('Please include the country code beginning with ‘+’.', 'countryCodeNotification');

       }

       else {

           telephoneField.clearNotification('countryCodeNotification');

       }

    }

  • necsa Profile Picture
    3,455 on at

    The aditional following link will be also helpful for you.

    www.jqueryscript.net/.../jQuery-International-Telephone-Input-With-Flags-Dial-Codes.html

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 196 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans