我想验证“联系方式7”印度10位数字的电话号码验证没有插件。
下面是我在插件中使用的模式:
因此,在Contact Form 7 formatting.php模块中,我像这样进行了更改,但仍然没有进行验证:
function wpcf7_is_tel( $tel ) {
$result = preg_match( '/^[+]?[0-10() -]*$/', $tel );
return apply_filters( 'wpcf7_is_tel', $result, $tel );
}发布于 2019-11-15 20:39:05
所以,在Contact Form 7 formatting.php模块中,
function wpcf7_is_tel( $tel ) {
$result = preg_match( '/^[+]?[0-9() -]*$/', $tel );
return apply_filters( 'wpcf7_is_tel', $result, $tel );
}替换为添加图案行/^(1-)?0-9{10}$/i
function wpcf7_is_tel( $tel ) {
$result = preg_match( '/^([1]-)?[0-9]{10}$/i', $tel ); // added line
return apply_filters( 'wpcf7_is_tel', $result, $tel );
}注意:最多支持10位
发布于 2019-11-15 20:41:18
这应该能起到作用
function wpcf7_is_tel( $tel ) {
$result = preg_match( '^\d{10}$/i', $tel ); // added line
return apply_filters( 'wpcf7_is_tel', $result, $tel );
}https://stackoverflow.com/questions/58877082
复制相似问题