Forum Discussion
Zaya__OSSE-Cont
7 years agoQrew Trainee
Sorry to resurrect an old post but this is the closest post I've found that's similar to the problem I'm struggling with.
I have a text field that's supposed to have all numbers except for dashes. I need to do IsNumeric type of validation. While Mark's formula is working great, my field can start with 0 so I can't use it. And changing the field to numeric is not an option at this point due to other dependencies. I've tried many different approaches with no luck. Any help would be greatly appreciated.
I have a text field that's supposed to have all numbers except for dashes. I need to do IsNumeric type of validation. While Mark's formula is working great, my field can start with 0 so I can't use it. And changing the field to numeric is not an option at this point due to other dependencies. I've tried many different approaches with no luck. Any help would be greatly appreciated.
- GiuseppeMacri7 years agoQrew Captainif it starts with a 0, why not create a formula to remove the initial 0?
- AustinK7 years agoQrew CommanderWhen I needed to verify something was a number(mine had 2 dashes between the numbers) I made a formula checkbox that would trigger if it was not a good number. I removed the dashes with a Part formula and then put all 3 parts back together in a variable. Then I tested to see if the number was above or below a certain number. My number was similar to a phone number so I checked if it was more than 0000000000 and less than 9999999999. If it returned true then it was a number. If it returned false it was not and I could abort the save.
The main issue with this approach is that for form rules to take effect the person needs to enter the data in the field and then click outside of the field to another one. If they do not do this then the form rule fails and the save happens.
I came to the conclusion that the best way to do this is with JavaScript. You can actually validate data with that and prevent people from entering the wrong thing. It's a nightmare doing it native in QuickBase imo. - QuickBaseCoachD7 years agoQrew CaptainCan you tell me what the format is, especially how many digits there are, excluding the dashes? Maybe post a typical example?
- Zaya__OSSE-Cont6 years agoQrew TraineeIt's SSN field that allows either null, all 9 digits or just last 4 digits. So the format is either empty, 123-456-789 or 0123.
- QuickBaseCoachD6 years agoQrew CaptainHere is a good strat to validating the SSN
var text RemoveDashes = SearchAndReplace([SSN],"-","");
var text DigitOne = Mid($RemoveDashes,1,1);
var text DigitTwo = Mid($RemoveDashes,2,1);
var text DigitThree = Mid($RemoveDashes,3,1);
var text DigitFour = Mid($RemoveDashes,4,1);
var text DigitFive = Mid($RemoveDashes,5,1);
var text DigitSix = Mid($RemoveDashes,6,1);
var text DigitSeven = Mid($RemoveDashes,7,1);
var text DigitEight = Mid($RemoveDashes,8,1);
var text DigitNine = Mid($RemoveDashes,9,1);
(Contains("0123456789", $DigitOne) or $DigitOne = "")
and
(Contains("0123456789", $DigitTwo) or $DigitTwo = "")
and
(Contains("0123456789", $DigitThree) or $DigitThree = "")
and
(Contains("0123456789", $DigitFour) or $DigitFour = "")
and
(Contains("0123456789", $DigitFive) or $DigitFive = "")
and
(Contains("0123456789", $DigitSix) or $DigitSix = "")
and
(Contains("0123456789", $DigitSeven) or $DigitSeven = "")
and
(Contains("0123456789", $DigitEight) or $DigitEight = "")
and
(Contains("0123456789", $DigitNine) or $DigitNine = "")
and
(Length($RemoveDashes)=0 or Length($RemoveDashes)=4 or Length($RemoveDashes)=9) - Zaya__OSSE-Cont6 years agoQrew TraineeThis great, thank you!!! Funny enough, I just had an idea to use contains last night but hadn't actually implemented it.