Hello,
I’m using the gform_field_validation to verify the applicant is in the correct zip code before moving on. I enter a valid zip code but I still get the invalid message.
Form can be seen here.
This is my code
//GRAVITY FORMS ZIP CODE AUTHENTICATION
add_filter( 'gform_field_validation_15_193', 'custom_zip_validation', 10, 4 );
function custom_zip_validation( $result, $value, $form, $field ) {
if ( $result['is_valid'] ) {
$acceptable_zips = array(
'91901',
'91976',
'92040',
'92085',
'92123',
'92160',
'91902',
'91977',
'83687',
'83709',
'83720',
'83756',
'83631',
'83652',
'83701',
'83711',
'83722',
'83799',
'83301',
'83302',
'83303',
'83647'
);
if ( ! in_array( $zip_value, $acceptable_zips ) ) {
$result['is_valid'] = false;
$result['message'] = 'Zip validation failed. Unfortunately, we are not able to assist you. We currently serve the areas within an hour San Diego County, Santa Ana, California; and Boise, Idaho. Please visit the Assistance Dogs International (ADI) website for more information on service dog training. <a href="https://www.assistancedogsinternational.org/" target="_blank">https://www.assistancedogsinternational.org/</a>
';
}
}
return $result;
}