Often times our customers autofill will put their email in the First Name field.
I found a solution to only allow letters and spaces and when I enable it works! It stops the special characters. But now it doesnt allow anything. I even tried all lower case text only and it gives me an error as if I entered special characters.
No problem. I included it before. I linked to an article you had helped someone else with.
Here it is directly.
add_filter( 'gform_field_validation', function( $result, $value, $form, $field ) {
if ( strpos( $field->cssClass, 'require_alpha_num' ) !== false && ! ctype_alnum( $value ) ) {
$result['is_valid'] = false;
$result['message'] = 'Error: You are not allowed to use special characters';
}
return $result;
}, 10, 4 );
I had reached out to GF support a little while back but it was too advanced for me. This is what they provided me with.
—————
Email from Gravity Forms
—————
Hello! You could hook to the filter gform_field_validation in order to check the value being submitted to that specific input on the name field. See the example 4. Name field validation for how you can investigate the various inputs of the name field as they are submitted. Checking for the existence of the @ character would seem to be sufficient in catching these.
———
END
———