I just noticed a bug that I need to fix. I have an ID text control that checks to see if you entered a 7 digit number. It works only if your 7 digit value does not start with a zero. For example 0000001 would be a number I would want to enter but that field validation sees only the 1. Is there a way to alter this code so it sees the starting zero and count from there?
If(
Value(Self.Text) < 1000000 || Value(Self.Text) > 9999999,
Reset(Self);
Notify("Reference ID Should be 7 digits. Drop any letters.")
)
Good job @Rajkumar_404 ! You got to it just before I did.
-Mark
Hi @futr_vision
The following should work using IsMatch and a regular expression.
If(
!IsMatch(Self.Text, "^(?=.{7}$)[0-9]+$"),
Reset(Self);
Notify("Reference ID should be 7 digits. Drop any letters.")
)
This checks to make sure the value is a 7 digit number and is exactly 7 digits.
-Mark
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.
Hi @futr_vision
Try these formulas,
If(
Len(Self.Text) <> 7 || !IsNumeric(Self.Text),
Reset(Self);
Notify("Reference ID should be 7 digits and contain only numbers.")
)
(Or)
If(
Len(Self.Text) <> 7 || !IsMatch(Self.Text, "^\d{7}$"),
Reset(Self);
Notify("Reference ID should be exactly 7 digits.and contain only numbers..")
)
Thanks!
If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional