Set a Minimum Dollar Value [RESOLVED]

Hi. My name is Eddie representing the client.

I have a donation page that is using authorize .net add-on. I created a ‘Price’ field labeled ‘Amount’. What I want to happen is to set a minimum amount of $10. So if visitors try to enter an amount lower than $10 it should not submit (process) the form alerting them to correct the entry to be $10 or more.

In a nutshell, I want to disallow donors from entering any amount under $10.

Thank you.

.

Gravity Forms does not have the capability to do that built in. However there is a plugin that can help:

Or you can code something using the gform_filed_validation filter to return a validation error if they submit less than 10 in the donation amount:

Thank you for the links. I attempted to use the documentation to apply gform_field_validation but it did not work. The doc is a little vague and so I may have misinterpret it. I am using this:

**<script>**

** add_filter( ‘gform_field_validation_14_12’, ‘custom_validation’, 10, 4 );**
** function custom_validation( $result, $value, $form, $field ) {**
** //change value for price field to just be numeric (strips off currency symbol, etc.) using Gravity Forms to_number function**
** //the second parameter to to_number is the currency code, ie “USD”, if not specified USD is used**
** $number = GFCommon::to_number( $value, ‘’ );**


** if ( $result[‘is_valid’] && intval( $number ) < 10 ) {**
** $result[‘is_valid’] = false;**
** $result[‘message’] = ‘You must enter at least $10.’;**
** }**
** return $result;**
** }**
** **

This is my form showing only the form id and the input field is:

<form method="post" enctype="multipart/form-data" id="**gform_14**" class="sidebar-donate" action="/give-2/">
                        <div class="gform_heading">
                            <h3 class="gform_title">Give (1)</h3>
                            <span class="gform_description"></span>
                        </div>
                        <div class="gform_body"><ul id="gform_fields_14" class="gform_fields top_label form_sublabel_above description_above"><li id="field_14_12" class="gfield gfield_price gfield_price_14_12 gfield_product_14_12 gfield_contains_required field_sublabel_above field_description_above gfield_visibility_visible"><label class="gfield_label" for="input_14_12">Amount<span class="gfield_required">*</span></label><div class="ginput_container ginput_container_product_price">
					<input name="input_12" id="**input_14_12**" type="text" value="10.00" class="medium ginput_amount" aria-required="true" aria-invalid="false">
        				</div>
</form>

I am sure I am missing something but I am not seeing it.

Here’s the url:
https://soulchoiceministries.org/give-2/

I recommend submitting a support ticket so we can help you with the gform_field_validation code:

Thank you.

Is there a way to set a minimum amount for the “Form Total” or a calculated field? The add-on mentioned appears to only be able to set a min/max for a product (user defined price) field.

In case anybody else needs this, here is the code that I used on form 225, field 8. This field is a Product field, because that is where I want my error validation message to appear. It can be used on other fields as well, such as the Total field, if needed.

add_filter( 'gform_field_validation_225_8', 'donate_minimum_validation', 10, 4 );
function donate_minimum_validation( $result, $value, $form, $field ) {
    $min_amount = 25.00;
    $donated = str_replace('$', '', $value);
    if ( $donated < $min_amount ) {
        $result['is_valid'] = false;
        $result['message'] = 'A minimum amount of $'.$min_amount.'.00 is required to offset credit card processing fees.';
    }
    return $result;
}
6 Likes

Thank you so much for posting this snippet!

1 Like