phone validation woocommerce
-
I’m trying to validate the next code of woocommerce to only accept 10 digits not more and not less. I already found a regex but not sure why I still can put more than 10 digits yet
/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/
the code on the woocommerce files is:
/**
* Validates a phone number using a regular expression
*
* @param string phone number
* @return bool
*/
public static function is_phone( $phone ) {
if ( strlen( trim( preg_replace( ‘/[\s\#0-9_\-\+\(\)]/’, ”, $phone ) ) ) > 0 )
return false;return true;
}
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘phone validation woocommerce’ is closed to new replies.