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! 🙂
Solved! Go to Solution.
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:
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
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:
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:
Best regards,
Kris
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:
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
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
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
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
204 | |
70 | |
51 | |
48 | |
20 |
User | Count |
---|---|
259 | |
120 | |
85 | |
80 | |
68 |