cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bobbybob
Helper II
Helper II

Text box validation for numbers and letters

Hello,

 

I'm not sure if this is possible but I'm trying to find a formula to populate an error message on a form when the user does not enter the right information. The information needs to be 3 letters and 3 numbers (ABC123). There are certain letters that should be used but they can be placed in any order. I would prefer that I could specify in the validation those letters but if not then just an error stating they did not enter the correct format would be better than nothing. Thanks for any information you can provide. 

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you but I ended up figuring it out. I used this formula in the Fill property.

 

If(Not(IsBlank(DataCardValue9.Text)),If(IsMatch(DataCardValue9.Text, "[E,T,N]{3}\d{3}") && Len(TextFormat.Text),RGBA(0, 0, 0, 0),RGBA(255, 0, 0, 0.5)))

View solution in original post

2 REPLIES 2
Drrickryp
Super User
Super User

@bobbybob 

Put this formula  in the error message for the card containing your textinput box.  Change the name in the formula from TextInput1 to the name of your textinput box and limit the MaxLength property of the textinput box to 6.

 

If(
    Len(TextInput1.Text) > 0 && !IsMatch(
        Left(
            TextInput1.Text,
            3
        ),
        "[a-zA-Z\s]+"// you can specify your letters here
    ),
    "Values muat start with three letters",
    Len(TextInput1.Text) = 6 && !IsNumeric(
        Right(
            TextInput1.Text,
            3
        )
    ),
    "The final 3 values must be numbers"
)

 

 

 

 

Thank you but I ended up figuring it out. I used this formula in the Fill property.

 

If(Not(IsBlank(DataCardValue9.Text)),If(IsMatch(DataCardValue9.Text, "[E,T,N]{3}\d{3}") && Len(TextFormat.Text),RGBA(0, 0, 0, 0),RGBA(255, 0, 0, 0.5)))

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,846)