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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / retain leading zero in...
Power Pages
Answered

retain leading zero in model driven app

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone,

 

I have a work phone number column which is a whole number and it should have a length of 10 digits. However, when a user enters a phone number starting with 0, that 0 is omitted. I want to retain that leading 0. Is there any way I can bring it in the form of a model-driven app?

 

hafizsultan242_0-1691543143881.png

 

 

@saudali_25  , @Lucas001 , @Mglat  , @ragavanrajan   Any thoughts on this please? Thank you

 

Kind Regards, 

Hafiz

 

 

Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,505 Super User 2026 Season 1 on at

    You cannot use a Number field (Decimal/Float etc).  You would need to use a Single line Text field instead .

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Fubar ,

     

    Thank you for your swift response. It is really appreciated. Have a nice day!!

     

    Kind Regards,

    Hafiz

  • Marcel Lathouwers Profile Picture
    237 on at

    If you want to completely stick to the no code option, then you can create a business rule that checks if the field starts with a zero and then gives an error. That way the user will be notified but must correct his own faulty input.

     

    The other option is to create a short javascript that controls and checksthe input given

  • Lucas001 Profile Picture
    2,567 Super User 2026 Season 1 on at

    Hi @Anonymous,

     

    one additional thing as you want to validate your phone number I believe.

    You can set a business rule for validation: https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/client-scripting

     

    @Fubaralready posted something about that here: https://powerusers.microsoft.com/t5/Microsoft-Dataverse/Validation-implementation-in-Model-driven-apps/td-p/839865

  • Marcel Lathouwers Profile Picture
    237 on at

    I have used this script recently. I would like to thank the author, but don't remember where on the internet I found it. 

    It removes letters from the phone number. The script is triggered on the OnChange of the field. 

    Your requirement is a bit different, but doable with regex, ask bing chat 😉

    function validatePhoneNumber(context) {
     var phoneNumberField = context.getEventSource(); // Get the field that triggered the onChange event
     var phoneNumberValue = phoneNumberField.getValue();
     var disallowedPattern = /[a-zA-Z]/g; // Regular expression to match all alphabet characters
    
     if (phoneNumberValue && disallowedPattern.test(phoneNumberValue)) {
     alert("Please enter a valid phone number without alphabet characters.");
     // Replace alphabet characters with an empty string to remove them
     phoneNumberValue = phoneNumberValue.replace(disallowedPattern, "");
     phoneNumberField.setValue(phoneNumberValue); // Update the field value without alphabet characters
     }
    }

     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 50

#2
Valantis Profile Picture

Valantis 26

#3
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard