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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I maintain proc...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 831 Moderator

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:
I have the same question (0)
  • Verified answer
    Rajkumar_M Profile Picture
    3,741 Super User 2025 Season 2 on at

    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.

  • MarkRahn Profile Picture
    1,231 Super User 2025 Season 2 on at

    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.

  • MarkRahn Profile Picture
    1,231 Super User 2025 Season 2 on at

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

    -Mark

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard