Round up form field

Hi everyone could someone show me the light.
I Have asked The holy G :slight_smile: but he/she couldn’t find anything for me.

My simple problem:
How do I make a form field to output, to be round up to next integer.
Example 1,1 should output 2
2.56 should output 3.

1 Like

Take a look at this free plugin from Gravity Wiz:

Thanks. But does gravity Wiz support decimals?

I was looking at the plugin before asking here, but when I read about it seems as not?

Good question. Did you ask Gravity Wiz, or download the plugin to give it a try?

I was on my way to give it a test, but found in some support thread that they didn´t support decimals :slight_smile: But I send them a mail right away then we get some facts.

I love this snippet, we use it a lot throughout our forms but can you tell me is there any way to round to the nearest increment of less than 1 but greater than 0? For instance, I tried to use gw-round-up-0.1 but it doesn’t seem to work. Is there any way to accomplish this?

Reply

  • Scott Buchmann says

I found the support thread:

"February 21, 2020 at 10:13 am

Hi Jon, rounding by decimals is not supported currently. You could handle this by utilizing [Copy Cat] Drop us after purchasing a Gravity Perks license and we can walk you through it."

But its seems like there is a workaround.

I’m not aware of another coded solution available. Without using something like this, you would need to use your own JavaScript/jQuery function to perform the rounding on the page.

If it does not need to happen on the page, and can happen after the form is submitted, you can use the gform_field_validation filter:

Or, if you can perform the rounding after submission, you can use the gform_pre_submission filter:

Thanks Chris for your support!
I Will try using JavaScript ceil() Method if I could figure it out :slight_smile:

1 Like

I’m also looking for a simple way to either round up or down numbers with decimals to an integer. Either up or down depending on my selection.

Did you already try this?

I did not try it because of some comments on the page about numbers with decimals.

I need to be able to round a number down in one field and up in another field.

For example, I need field A to round up to the next integer. The number in field A might be 7.352 I need it to round up to 8.

For example, I need field B to round down to the next integer. The number in field B might be 7.736 and I need it to round down to 7.

Does that make sense?

Thanks for the quick response.

It makes sense. I recommend contacting the author for their support or assistance. The functionality you’re looking for does not exist in Gravity Forms, and that is the closest solution I know of. Otherwise, you’d be writing your own custom code.

I contacted Gravity Forms and they directed me to the same “Rounding by Increments with Gravity Forms” article.

There was a comment on the page that caught my attention. How do I use Copy Cat to accomplish rounding up or down decimal numbers?

CopyCat is a paid perk and with that you would have access to their support. I’m not sure how they work together - they have their own support for Gravity Perks and their Gravity Wiz snippets. Thank you.

Hey Chris,

The snippet Gravity Wiz provided did work for my use.

Thanks

1 Like

Hi, the snippet form Gravity Wiz worked out fine, but only when you present the result online. What if you want to send the rounded result in an email? Anyone know how to achieve that? Thanks

To anyone who also had issue with the rounded number not being visible in the emails: This only happened if i used the {all_fields} merge tags.

If i manually added all the merge tags, the rounded number was entered correctly into the email.

1 Like