Skip to main content
Community site session details

Community site session details

Session Id : iAxW7sKDhTgAOUDGXx4m8v
Power Apps - Building Power Apps
Answered

validating if numbers and letters are in a text input

Like (0) ShareShare
ReportReport
Posted on 4 Jan 2024 09:49:14 by 265

Hi,

I want to validate "123801902V" or "201923920v" text filed in a form in the power app .How I do it?

there should be 9 digits and one letter .

Thank you.

  • Erandi Profile Picture
    265 on 05 Jan 2024 at 04:53:08
    Re: validating if numbers and letters are in a text input

    Hi @enriqueglopez , If i use "0 " also into pattern. Can be this one?

    "^\d[0-9][vV]$"
  • enriqueglopez Profile Picture
    494 Moderator on 04 Jan 2024 at 10:42:55
    Re: validating if numbers and letters are in a text input

    Your validation is incorrect if you want to have only 6 digits (numbers).

    With your code, only the length of the input value will be evaluated, regardless of whether it is a number or text.

     

    I recommend you to use RegEx again. Its a better practice.

     

    Modify the previous RegEx from 

     

    "^\d{9}[vV]$"

     

    to

     

    "^\d{6}$"

     

     

    But, if you want to validate 6 characters length, numbers or text, you can use your code or this RegEx.

     

    "^[a-zA-Z0-9]{6}$"

     

    RegEx its really useful for validation.

  • Erandi Profile Picture
    265 on 04 Jan 2024 at 10:38:59
    Re: validating if numbers and letters are in a text input

    Hi guys,

    then if i want to validate 6 digits long ID.can I use like this?

    If(
            Len(txtEmplID.Text) = 6,
     
            UpdateContext({varShowErrorMsg:"Employee ID contains 6 digits"});
            UpdateContext({varShowError:true});        
            Reset(txtEmplID);
        )  
  • Verified answer
    ANB Profile Picture
    7,128 Super User 2025 Season 2 on 04 Jan 2024 at 10:22:42
    Re: validating if numbers and letters are in a text input

    @Erandi If last letter will always "V" or "v", this should also help you

     IsMatch(
     TextInput1.Text,
     Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Letter
     ) && ("V" in TextInput1.Text || "v" in TextInput1.Text)

     

    You can add above thing in the condition.

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


  • Verified answer
    enriqueglopez Profile Picture
    494 Moderator on 04 Jan 2024 at 10:16:44
    Re: validating if numbers and letters are in a text input

    Use this one instead

     

    "^\d{9}[vV]$"

     

     

    This Regex will validate that the first 9 characters are a number and the last is V or v.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it.

     

  • Erandi Profile Picture
    265 on 04 Jan 2024 at 10:14:06
    Re: validating if numbers and letters are in a text input

    hi @enriqueglopez ,

    i tried but i am getting error like this.

    Erandi_0-1704363239954.png

     

  • Erandi Profile Picture
    265 on 04 Jan 2024 at 10:11:51
    Re: validating if numbers and letters are in a text input

    Hi guys,

    If I use the numbers between 0 to 9, it should be 

    IsMatch(txtNIC.Text, "^\d[0,9][z-Z]$") ,
     
    am i right?
  • ANB Profile Picture
    7,128 Super User 2025 Season 2 on 04 Jan 2024 at 10:05:47
    Re: validating if numbers and letters are in a text input

    @Erandi Try this

    IsMatch(
     TextInput1.Text,
     Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Letter
    )

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


  • Erandi Profile Picture
    265 on 04 Jan 2024 at 10:02:25
    Re: validating if numbers and letters are in a text input

    Hi @mmbr1606 ,yes it can be "V" and "v". That is a  ID number pattern. So i want validate it when submitting to form.

  • enriqueglopez Profile Picture
    494 Moderator on 04 Jan 2024 at 10:02:00
    Re: validating if numbers and letters are in a text input

    You can use IsMatch function to compare your input value with a RegEx.

     

    For example:

     

     

    IsMatch(TextInput.Text, "^\d{9}[a-zA-Z]$")

     

     

    This Regex will help to reach what you want. You could do the validation like this:

     

    If(
     IsMatch(
     TextInput.Text,
     "^\d{9}[a-zA-Z]$"
     ),
     "Input is valid",
     "Input is not valid"
    )

     

    Ref: IsMatch, Match, and MatchAll functions - Power Platform | Microsoft Learn

     

    If this post helps, then please consider Accept it as the solution to help the other members find it.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2