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 / Validate Text Input ha...
Power Apps
Unanswered

Validate Text Input has more than 8 numbers

(1) ShareShare
ReportReport
Posted on by 41
Hello, 

I am using the modern text input field in a canvas app which I have added to a container. I want to be able to validate that the text input field has 8 characters or more. The text input cannot be blank and has to have 8 or more characters. I have the following code, but I get an error. 
If(
    And( Len(Self.Value)>= 8 , IsBlank(Self.Value),
    "Error",
    "None"
)

What is the best way for the validation state to check that it is not blank and has 8 or more characters in it? 
Categories:
I have the same question (0)
  • Suggested answer
    tsa-svd2srv Profile Picture
    204 on at
    If(
        Or(
            IsBlank(Self.Value),
            Len(Self.Value) < 8
        ),
        "Error",
        "None"
    )
    This should do it. Have fun!
  • Suggested answer
    Pstork1 Profile Picture
    68,697 Most Valuable Professional on at
    I would use a REGEX expression for this and an IsMatch() function.  This should work

    isMatch(self.Text, "^\d{8}$")

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
    ​​​​​​
  • Verified answer
    timl Profile Picture
    36,383 Super User 2025 Season 2 on at
     
    If you're curious as to why your formula caused an error, it was because you were missing a closing bracket after the And function.
     
    Irrespective of that, you would need to call the Or function to test that the value is greater than 8 characters OR "is blank". Note that the earlier post specified "< 8" which is incorrect. 
    If(
        Or(Len(Self.Value)> 8 , IsBlank(Self.Value)),
        "Error",
        "None"
    )
    
     
  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at
    Just to extend on @PStork1's Regex post below, you would need to add "^$" to also check for blank values, and specify {9,} if you don't want it to trigger for input that's exactly 8 characters long.
     
    If(
        IsMatch(Self.Value, "^$|^.{9,}$"),
        "Error",
        "None"
    )
    
     
  • tsa-svd2srv Profile Picture
    204 on at
    timl:
     
    If we look at your code (my code revised) with just the idea that it need to be 8 or more characters:
    If(
        Len(Self.Value)> 8,
        "Error",
        "None"
    )
    Your code results in "Error" if Len is greater than 8.
     
    This is backwards to the requesters post.
     
    The code I submitted is correct.
  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at
     
    Apologies, yes you're absolutely correct. I misread the question as the input text being no more than 8 characters.
     
    @ElvirBotic - perhaps you can mark @tsa-svd2srv post as the answer if it solves your problem.

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 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard