Implement custom validation for a specific field in a Gravity Form.
add_filter('gform_field_validation_1_2', 'codebykp_custom_validation', 10, 4);
function codebykp_custom_validation($result, $value, $form, $field) {
if ($field->id == 2 && !filter_var($value, FILTER_VALIDATE_EMAIL)) {
$result['is_valid'] = false;
$result['message'] = 'Please enter a valid email address.';
}
return $result;
}