cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NabeelNQ
Level: Powered On

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! Smiley Happy

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Max Length!!!!!!!!!!!!!!!!!

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.
6 REPLIES 6
Community Support Team
Community Support Team

Re: Max Length!!!!!!!!!!!!!!!!!

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.
NabeelNQ
Level: Powered On

Re: Max Length!!!!!!!!!!!!!!!!!

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! Smiley Happy

Community Support Team
Community Support Team

Re: Max Length!!!!!!!!!!!!!!!!!

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.
Community Support Team
Community Support Team

Re: Max Length!!!!!!!!!!!!!!!!!

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.
NabeelNQ
Level: Powered On

Re: Max Length!!!!!!!!!!!!!!!!!

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...

Highlighted
cvazquc3
Level: Powered On

Re: Max Length!!!!!!!!!!!!!!!!!

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