Hi all,
I’m having one of these blank/blocked moments.
In a nutshell, trying to validate entry for phone number. I’m building a customs form, as shown by @Darren_Murphy’s great example.
I’ve chosen the “Phone Entry” field. This field should accept, well you guessed it, just digit/numbers. It’s true that in some rather rare situations you do want to add letter or other characters, but I assume you’ll agree the default should be limited to just digits. The “Phone Entry” field is NOT limited to digits only, nor is it configurable in any way. Any ideas on how to validate that the input is just digits?
Wait, now comes the challenge:
Of course I’m using RegEx and it’s working flawlessly. However, it’s “firing” too early, such as:
RegEx is supposed to limit the first two characters to just “05”. For this reason, I’ve added a column to count the characters and the alerts only fires from the third characters onwards. This is to prevent the alert coming up within the first character input (even if that character is indeed “0” as it should be). The rest of the RegEx indeed limits to just digits and at a certain length.
I added another column with a math formula of “phone number”/“phone number”. It fires an alert if it’s equal to “” (left blank. For some reason it’s not working with entering “1”). However, the first character is 0 and 0/0 doesn’t equal 1.0… This causes the alert to fire when you enter the first (correct) character (“0”).
Any ideas?
I’m almost certain this is a very basic issue that I’m missing, but that’s how “writer’s block” work…
In my opinion, the phone entry accepts text as well because we can have cases where there are letters in the number, albeit in my understanding it might be an old-school way.
Nope. In my world (and in my contact list), any phone number that doesn’t start with + is an invalid number
Validating phone numbers with regex is a bit of a slippery slope. Every time you think you’ve nailed it, you’ll find another edge case that breaks it. And before you know it you’ll have something that looks like this:
You’re absolutely right and that’s why our RegEx doesn’t really check the phone number, rather its VERY general syntax. Far for failproof, but good enough for now.
I couldn’t find a tutorial for these JS columns. Is there one?
To be honest, I haven’t used RegEx on Glide APP so far but I have some Google Forms working this kind of requirement and can take a look at them and help later.