You can create custom validation rules for your fields to ensure the submitted data meets your criteria. Here’s an example of how to validate an email field.
add_filter('gform_field_validation', 'codebykp_custom_email_validation', 10, 4);
function codebykp_custom_email_validation($result, $value, $form, $field) {
if ($field->id == 2 && !is_email($value)) { // Assuming field ID 2 is for email
$result['is_valid'] = false;
$result['message'] = 'Please enter a valid email address.';
}
return $result;
}