2017-05-25 67 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。