mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
6 lines
395 B
Text
6 lines
395 B
Text
add_action( 'woocommerce_checkout_process', 'custom_checkout_field_validation', 10, 2 );
|
|
function custom_checkout_field_validation( $data, $errors ) {
|
|
if ( ! preg_match( '/^[a-zA-Z0-9@.-,]*$/', $data['billing_first_name'] ) ) {
|
|
$errors->add( 'validation_error', __( 'Error: Only a-z, A-Z, 0-9, @, hyphens, full-stops and commas are allowed in the field.', 'woocommerce' ) );
|
|
}
|
|
}
|