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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans