How to block links in text field? [RESOLVED]

Guys, thanks for your help! Here is the code that worked:

// add custom validation to form
add_filter( 'gform_field_validation_74_7', 'validate_phone_74_7', 10, 4 );
function validate_phone_74_7( $result, $value, $form, $field ) {
    $nourl_pattern = '(http|https)';
    if ( preg_match( $nourl_pattern, $value ) ) {
    $result['is_valid'] = false;
    $result['message']  = 'Message can not contain website addresses.';
}
return $result;
}
2 Likes