Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

How do I maintain proceeding zeros in a text field value?

(0) ShareShare
ReportReport
Posted on by 825 Super User 2025 Season 1

I just noticed a bug that I need to fix. I have an ID text control that checks to see if you entered a 7 digit number. It works only if your 7 digit value does not start with a zero. For example 0000001 would be a number I would want to enter but that field validation sees only the 1. Is there a way to alter this code so it sees the starting zero and count from there? 

 

 

If(
 Value(Self.Text) < 1000000 || Value(Self.Text) > 9999999,
 Reset(Self);
 Notify("Reference ID Should be 7 digits. Drop any letters.")
)

 

 

Categories:
  • MarkRahn Profile Picture
    973 Super User 2025 Season 1 on at
    Re: How do I maintain proceeding zeros in a text field value?

    Good job @Rajkumar_404 ! You got to it just before I did.

    -Mark

  • MarkRahn Profile Picture
    973 Super User 2025 Season 1 on at
    Re: How do I maintain proceeding zeros in a text field value?

    Hi  @futr_vision 

     

    The following should work using IsMatch and a regular expression.

     

    If(
     !IsMatch(Self.Text, "^(?=.{7}$)[0-9]+$"),
     Reset(Self);
     Notify("Reference ID should be 7 digits. Drop any letters.")
    )
    

    This checks to make sure the value is a 7 digit number and is exactly 7 digits.

     

    -Mark

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.

  • Verified answer
    Rajkumar_M Profile Picture
    3,631 Super User 2025 Season 1 on at
    Re: How do I maintain proceeding zeros in a text field value?

    Hi @futr_vision 

     

    Try these formulas,

     

    If(
    Len(Self.Text) <> 7 || !IsNumeric(Self.Text),
    Reset(Self);
    Notify("Reference ID should be 7 digits and contain only numbers.")
    )

    (Or)

     

    If(
    Len(Self.Text) <> 7 || !IsMatch(Self.Text, "^\d{7}$"),
    Reset(Self);
    Notify("Reference ID should be exactly 7 digits.and contain only numbers..")
    )

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard