Add phone number validation for non-numeric characters

This commit is contained in:
dinamiko 2022-06-22 10:48:56 +02:00
parent d7363a0d44
commit fcf9b6b19e
2 changed files with 198 additions and 115 deletions

View file

@ -347,7 +347,7 @@ class PayUponInvoice {
}
$national_number = filter_input( INPUT_POST, 'billing_phone', FILTER_SANITIZE_STRING );
if ( $national_number && ! preg_match( '/^[0-9]{1,14}?$/', $national_number ) ) {
if ( $national_number && ! preg_match( '/^[0-9]{1,14}?$/', preg_replace( '/[^0-9]/', '', $national_number ) ) ) {
$errors->add( 'validation', __( 'Phone number size must be between 1 and 14', 'woocommerce-paypal-payments' ) );
}
},