You are viewing limited content. For full access, please sign in.

Question

Question

How can I prevent leading zeroes from being removed in a number field?

asked on June 24, 2020

Is it possible to do this? I'd prefer to use a number field to restrict entries to numbers, but when we enter a number such as 001428, it truncates the leading zeroes to result in 1428. As this particular field in question is an org code, it needs to be accurate, and not all of our org codes lead with two zeroes, so I can't simply add the zeroes back in as the number of zeroes needed won't be consistent. 

Short of changing the field to a single line field, is there any way to accomplish this?

0 0

Answer

SELECTED ANSWER
replied on June 24, 2020

You can't; number fields don't work that way. You will need to use a single-line field, but you can use this regular expression to make sure it only allows numerical input: \d+

3 0
replied on June 24, 2020

Jim to the rescue, as always! Haha, thank you very much once again Jim! That will work perfectly. Have a great rest of your day!

2 0

Replies

replied on June 25, 2020

Great tip. There are at least 2 other similar use cases with leading zeros that come up in the US New England states - Zip codes and Social Security Numbers (SSN). On Cape Cod Massachusetts your postal code might be 02633. A helpful Regular Expression that covers New England zip codes that still works for Beverley Hills 90210 on the west coast of the US might look like ^\d{5}$|^\d{5}-\d{4}$.  This would allow a 5 digit zip code or the more precise "Zip+4" format. If you were issued a Social Security Number in a New England state or New York after 1973 you might have a number starting with one or 2 leading zeros such as 001-11-1111. A useful Regular Expression for SSNs might be ^\d{3}-\d{2}-\d{4}$.  

2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.