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.

View solution in original post

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_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,766)