【问题标题】:WordPress phone Number Restrict to allow xxx-xxx-xxxx FormatWordPress 电话号码限制允许 xxx-xxx-xxxx 格式
【发布时间】:2017-10-25 21:53:08
【问题描述】:

我已将占位符保留为 xxx-xxx-xxxx

<label> Phone Number </label> [number* shm-mrk-phone minlength:10 maxlength:140 placeholder "]

我在 pluginformatting.php 中更改了 tel 脚本

function wpcf7_is_tel( $tel ) {
    $result = preg_match( '/^(?:\(\d{3}\)|\d{3}-)\d{3}-\d{4}$/', $tel );
    return apply_filters( 'wpcf7_is_tel', $result, $tel );
}

它不允许xxx-xxx-xxxx(这应该允许),它允许xxxxxxxxx

【问题讨论】:

    标签: wordpress contact-form phone-number tel


    【解决方案1】:

    这很简单。我使用tel而不是号码类型来添加手机号码。

    在 Contact Form 7 插件formatting.php 模块中,

    我更新了wpcf7_is_tel 函数的代码。

    function wpcf7_is_tel( $tel ) {
        $result = preg_match( '/^(?:\(\d{3}\)|\d{3}-)\d{3}-\d{4}$/', $tel );
        return apply_filters( 'wpcf7_is_tel', $result, $tel );
    }
    

    工作正常。

    【讨论】:

      猜你喜欢
      • 2013-03-19
      • 2016-06-04
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 2011-09-02
      • 2016-12-24
      • 1970-01-01
      • 2021-01-01
      相关资源
      最近更新 更多