【发布时间】:2021-11-01 05:27:48
【问题描述】:
我正在使用联系表格 7,并希望禁止用户在电话字段中输入重复的数字,例如 1111111 或 2222222。
我使用以下代码仅输入 10 位数字。任何人都可以帮助我解决我应该更改或添加的内容。
// define the wpcf7_is_tel callback<br>
function custom_filter_wpcf7_is_tel( $result, $tel ) {<br>
$result = preg_match( '/^\(?\+?([0-9]{0})?\)?[-\. ]?(\d{10})$/', $tel );<br>
return $result; <br>
}<br>
add_filter( 'wpcf7_is_tel', 'custom_filter_wpcf7_is_tel', 10, 2 );
【问题讨论】:
-
一个数字可以重复多少次才能使该数字无效?
-
允许的数字是 10,但不希望相同的数字重复超过 5 次。也只想入手 6,7,8 & 9
标签: preg-match contacts phone-number