2017-05-25 63 views
2

我一直占位符为XXX-XXX-XXXXWordPress的电话号码限制,让XXX-XXX-XXXX格式

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

我改变formatting.php在插件中的电话脚本

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(这应该允许),它允许xxxxxxxxxx

回答

0

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

在联系表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); 
} 

Works Fine。