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

Max Length!!!!!!!!!!!!!!!!!

Hello Everyone,

 

I have another doubt,

 

 I want to the max length of a text input be set to a condition. I fthe user is entering an email address, then 40, if it is a numerical value (Phone Number), then 10.

Also, can you please provide some examples to use Max Length in PowerApps.

 

Thanks and a Happy New Year! 🙂

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @NabeelNQ,

Do you want to not allow the user to enter more than 10 digits in the first place?

Based on the needs that you mentioned, I think the Timer control could achieve your needs.

I have made a test on my side, please take a try with the following workaround:8.JPG

 

9.JPG

Add a Timer control within your app, set the Duration property to following:

1000

Set the Repeat property and AutoStart property to following:

true

Set OnTimerEnd property to following:

If(
IsMatch(TextInput1.Text, Match.Email),
Set(MaxValue, 40),
IsMatch(TextInput1.Text,"\d{10}"), /* <-- Modify formula here */
Set(MaxValue,10),
Len(TextInput1.Text)=0, /* <-- Add formula here */
Set(MaxValue, Blank())
)

Set the MaxLength property of the Text Input control to following:

MaxValue

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-xida-msft
Community Support
Community Support

Hi @NabeelNQ,

Do you want to set the Max Length of the Text Input box based on the user's input (Phone number or email address)?

Based on the needs that you mentioned, I think the IsMatch function could achieve your needs.

I have made a test on my side, please take a try with the following workaround:2.JPG

 

3.JPG

Set the OnChange property of the Text Input box (TextInput1) to following:

If(
IsMatch(TextInput1.Text, Match.Email),
Set(MaxValue, 40),
IsMatch(TextInput1.Text,"\d+"),
Set(MaxValue,10)
)

Set the OnSelect proeprty fo the Text Input control to following:

Set(MaxValue, Blank())

Set the MaxLength proeprty fo the Text Input box to following:

MaxValue

Please check the attached GIF screenshot for more details:

 

More details about the IsMatch function, please check the following article:

IsMatch function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much Kris once again!

The solution you provided is working, but at the same time, it is allowing the User to enter more than 10 digits for the numbers, and then when I select something else, it deletes the numbers after the 10th Number.

 

Is there a way where I cannot allow the user to enter more than 10 digits in the first place.

 

Thanks! 🙂

Hi @NabeelNQ,

Do you want to not allow the user to enter more than 10 digits in the first place?

Based on the needs that you mentioned, I think the Timer control could achieve your needs.

I have made a test on my side, please take a try with the following workaround:8.JPG

 

9.JPG

Add a Timer control within your app, set the Duration property to following:

1000

Set the Repeat property and AutoStart property to following:

true

Set OnTimerEnd property to following:

If(
IsMatch(TextInput1.Text, Match.Email),
Set(MaxValue, 40),
IsMatch(TextInput1.Text,"\d{10}"), /* <-- Modify formula here */
Set(MaxValue,10),
Len(TextInput1.Text)=0, /* <-- Add formula here */
Set(MaxValue, Blank())
)

Set the MaxLength property of the Text Input control to following:

MaxValue

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @NabeelNQ,

Have you taken a try with above solution I provided?

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved for other users.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks a lot for the reply! Sorry for the delay!

 

Seems like the first solution you provided is working on its own...

 

Now I cant seem to type more than 10 digits.

 

Thanks again...

There are many configurations to achieve this.
I did it in the following way
1- Select the control text input
2.- In the MaxLength property, type 10

regards

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,807)