Title: Regex Validation for Gravity Forms
Author: Daniel Sturm
Published: <strong>2026 年 2 月 25 日</strong>
Last modified: 2026 年 2 月 25 日

---

搜索插件

![](https://ps.w.org/regex-validation-for-gravity-forms/assets/banner-772x250.png?
rev=3469406)

![](https://ps.w.org/regex-validation-for-gravity-forms/assets/icon.svg?rev=3469406)

# Regex Validation for Gravity Forms

 作者：[Daniel Sturm](https://profiles.wordpress.org/dsturm/)

[下载](https://downloads.wordpress.org/plugin/regex-validation-for-gravity-forms.zip)

 * [详情](https://cn.wordpress.org/plugins/regex-validation-for-gravity-forms/#description)
 * [评价](https://cn.wordpress.org/plugins/regex-validation-for-gravity-forms/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/regex-validation-for-gravity-forms/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/regex-validation-for-gravity-forms/#developers)

 [支持](https://wordpress.org/support/plugin/regex-validation-for-gravity-forms/)

## 描述

**Regex Validation for Gravity Forms** adds a powerful regex validation option to
your Gravity Forms fields. Define custom regular expression patterns or choose from
built-in presets to validate user input — both server-side and client-side.

#### Features

 * **Custom regex patterns** — Add any regular expression to validate field input
 * **Unicode support** — Full Unicode character class support (`\p{L}`, `\p{N}`)
   for international names and text
 * **Built-in presets** — Quick-select common patterns for names, emails, phone 
   numbers, and more
 * **Server-side validation** — Secure PHP validation that can’t be bypassed
 * **Client-side validation** — Instant feedback on input change using JavaScript
 * **Compound field support** — Works with Name fields (validates each sub-input
   individually)
 * **Custom error messages** — Define user-friendly validation messages per field
 * **Extensible** — Add your own presets and field types via filters
 * **Accessible** — Error messages use `role="alert"` for screen readers

#### Supported Field Types

 * Text
 * Name (with individual sub-input validation)
 * Email
 * Phone
 * Website
 * Textarea

#### Built-in Presets

 * **Name** — Unicode letters, spaces, hyphens, apostrophes
 * **Email** — RFC 5322 compliant
 * **US Phone Number** — Common US formats
 * **International Phone Number** — E.164 format
 * **Alphanumeric** — Unicode letters and numbers only
 * **No Special Characters** — Unicode letters, numbers, and spaces only

## 安装

#### From WordPress Admin

 1. Upload the `regex-validation-for-gravity-forms` folder to `/wp-content/plugins/`
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

#### Via Composer

    ```
    composer require zirkeldesign/regex-validation-for-gravity-forms
    ```

#### Requirements

 * WordPress 6.0 or later
 * PHP 8.2 or later
 * Gravity Forms 2.5 or later

## 常见问题

### How do I add a regex pattern to a field?

Edit your form in Gravity Forms, select a supported field, and look for the “Regex
Validation” section under the field settings. You can either select a preset pattern
or enter your own custom regex.

### Does it support Unicode characters?

Yes! All patterns use the `/u` flag for PHP and the `u` flag for JavaScript regex,
enabling full Unicode property support like `\p{L}` for any letter in any language.

### Can I add my own presets?

Yes, use the `gf_regex_validation_presets` filter:

    ```
    add_filter('gf_regex_validation_presets', function (array $presets): array {
        $presets['zip_code'] = [
            'label'   => 'US Zip Code',
            'pattern' => '/^\d{5}(-\d{4})?$/',
            'message' => 'Please enter a valid US zip code.',
        ];

        return $presets;
    });
    ```

### Can I add support for additional field types?

Yes, use the `gf_regex_validation_field_types` filter:

    ```
    add_filter('gf_regex_validation_field_types', function (array $types): array {
        $types[] = 'number';

        return $types;
    });
    ```

### Is client-side validation secure?

Client-side validation provides instant user feedback but should never be relied
upon for security. This plugin always performs server-side validation as well, which
cannot be bypassed.

## 评价

此插件暂无评价。

## 贡献者及开发者

「Regex Validation for Gravity Forms」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Daniel Sturm ](https://profiles.wordpress.org/dsturm/)
 *   [ dsturm ](https://profiles.wordpress.org/dsturm-1/)

[帮助将「Regex Validation for Gravity Forms」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/regex-validation-for-gravity-forms)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/regex-validation-for-gravity-forms/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/regex-validation-for-gravity-forms/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/regex-validation-for-gravity-forms/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/regex-validation-for-gravity-forms/)。

## 更新日志

#### 1.0.2

 * Fixed: Admin field settings not appearing in Gravity Forms editor
 * Improved: Code quality and WordPress coding standards compliance
 * Enhanced: Development tooling for better maintainability

#### 1.0.1

 * Fixed: WordPress Plugin Check compliance issues
 * Improved: Security and code standards

#### 1.0.0

 * Initial release
 * Server-side and client-side regex validation
 * Built-in presets for common patterns
 * Unicode support with `\p{L}` and `\p{N}` character classes
 * Name field compound input support
 * Extensible via `gf_regex_validation_presets` and `gf_regex_validation_field_types`
   filters

## 额外信息

 *  版本 **1.0.3**
 *  最后更新：**2 月前**
 *  活跃安装数量 **不到10**
 *  WordPress 版本 ** 6.0 或更高版本 **
 *  已测试的最高版本为 **6.9.4**
 *  PHP 版本 ** 8.3 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/regex-validation-for-gravity-forms/)
 * 标签
 * [gravity forms](https://cn.wordpress.org/plugins/tags/gravity-forms/)[pattern](https://cn.wordpress.org/plugins/tags/pattern/)
   [regex](https://cn.wordpress.org/plugins/tags/regex/)[unicode](https://cn.wordpress.org/plugins/tags/unicode/)
   [validation](https://cn.wordpress.org/plugins/tags/validation/)
 *  [高级视图](https://cn.wordpress.org/plugins/regex-validation-for-gravity-forms/advanced/)

## 评级

尚未提交反馈。

[Your review](https://wordpress.org/support/plugin/regex-validation-for-gravity-forms/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/regex-validation-for-gravity-forms/reviews/)

## 贡献者

 *   [ Daniel Sturm ](https://profiles.wordpress.org/dsturm/)
 *   [ dsturm ](https://profiles.wordpress.org/dsturm-1/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/regex-validation-for-gravity-forms/)