我想验证一下印度的手机号码。手机号的格式如下:
9775876662、8156652458、7596658556、6655485568
下面的regEx:
function wpcf7_is_tel( $tel ){
$pattern = '%^[+]?' // + sign
. '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234
. '(?:[/ -]*' // delimiter
. '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234
. ')*$%';
$result = preg_match( $pattern, trim( $tel ) );
return apply_filters( 'wpcf7_is_tel', $result, $tel );
}我想改变一下模式。请帮帮忙。
发布于 2021-05-17 18:17:10
你可以使用wpcf7_is_tel过滤器钩子。
function valid_indian_mobile_number( $result, $tel ) {
$result = preg_match( '/^[6-9][0-9]{9}$/', $tel );
return $result;
}
add_filter( 'wpcf7_is_tel', 'valid_indian_mobile_number', 10, 2 );有用的链接
https://stackoverflow.com/questions/67564590
复制相似问题