Number fields removes 0 if it's entered at the beginning of the number

Hi, I have a number form that might get a value that start with 0 but it seems that it is being removed. How can I make sure that the number stays as it is, even if the first number is 0?


You will need to use a single line text field if you need to preserve the leading zero(es).

Thanks. Is there a way to limit a single line text field to only accept numbers?

Yes, you can enable the input mask, via a checkbox on the settings for the text field. What sort of values do you expect to be input in this field? Is the value always the same number of characters, but you need to allow the leading zeroes to be preserved? Can you give some examples of the numbers that will be submitted?

It will only be numbers. Its going to be an ID number and I need to keep the 0 if it located at the beginning of the number. It will be a 9 digit number if that matters.

Yes, if it is always 9 digits and you need to keep the leading zero, you can use the single line text field and check the box “Input Mask”, select “Custom” radio button, then enter nine 9’s in the input. Your custom mask will look like this:



When submitting the form, this is how the value is captured:

Thanks Chris :slight_smile:

On a different note, do you have a good tutorial on using math calculations inside Gravity Forms?

We don’t have a good tutorial I don’t think. This is the only documentation I am aware of:

We were / are having this problem too. The above method with the masks helps to keep the initial zero’s in the data stored in the form entries, however when you export this to a CSV file through ‘forms -> import/export’ the zeros disappear. Is there any work around for this? We are having the same issues whether it is a number or text field. Any help would be gratefully appreciated.

Chances are, the spreadsheet you are using is interpreting the field as a number field rather than a text field. Open the CSV with a text editor, and see if the zeroes are present. If they are, then the spreadsheet is incorrectly making that field a number value rather than a text value. There is probably a setting when you import the CSV to not do that automatically.

© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.