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 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:
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;
}