# How to block links in text field? \[RESOLVED\]

**URL:** <https://community.gravityforms.com/t/how-to-block-links-in-text-field-resolved/5865>\
**Category:** Get Help\
**Tags:** gform\_field\_validation, spam\
**Created:** [August 24, 2020, 3:51pm UTC](https://community.gravityforms.com/t/how-to-block-links-in-text-field-resolved/5865 "2020-08-24T15:51:11Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![user5b199982d16560.5](https://avatars.discourse-cdn.com/v4/letter/u/e95f7d/32.png) [@user5b199982d16560.5](https://community.gravityforms.com/u/user5b199982d16560.5)\
**Post date:** [August 25, 2020, 12:16am UTC](https://community.gravityforms.com/t/how-to-block-links-in-text-field-resolved/5865/6 "2020-08-25T00:16:07Z")

</div>

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;
}
```

---

_[View the full topic](https://community.gravityforms.com/t/how-to-block-links-in-text-field-resolved/5865)._
