Hi power community,
Here is the problem:
I need to autoformat a textinput while the user is typing in it. It's not so simple as autoformatting currency because the field is a driver license number with the following pattern:
"[a-zA-Z]" & Digit & Digit & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit & Digit
For example: A1234-12345-12345
Until now, I've managed to do something similar with the following approach (if the pattern is just numbers works fine):
Using 2 controls: Timer1 and TextInput1
TextInput1 properties: default = var / Maximum length = 17
Timer1 properties: Duration= 2 / Repeat = on / OnTimerStart = as the below image
The problem with that approach is if I insert a letter won't work (probably because of the Value function).
Do you know how I can solve this?
Thanks!
Thanks for sharing. I already knew these links, they help me to solve the problem for only numbers pattern.
But I don't know how to adapt to a pattern that contains a letter in the first place (e.g.: A1234-12345-12345)
HI @Frederico ,
This will do the job at the end of the input (of 14 characters) on the OnChange of the Text box
UpdateContext(
{
varText: Self.Text,
varLen: Len(Self.Text)
}
);
If(
varLen >= 14,
UpdateContext(
{
varText:
Left(
varText,
5
) & "-" &
Mid(
varText,
6,
5
) & "-" &
Mid(
varText,
11,
5
)
}
);
Reset(Self)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
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 |
---|---|
200 | |
69 | |
50 | |
46 | |
20 |
User | Count |
---|---|
258 | |
121 | |
84 | |
79 | |
69 |