Can anyone help me limit the zip code field to 5 character in my WooCommerce checkout page?
I’ve tried adding MAXLENGTH to the field but that doesn’t work also tried adding script to the function.php file that seems to work on the billing address but not the Billing details zipcode field.
function my_wc_custom_billing_fields( $fields ) {
$fields[‘billing_postcode’][‘maxlength’] = 5;
return $fields;
}
add_filter( ‘woocommerce_billing_fields’, ‘my_wc_custom_billing_fields’ );
function my_wc_custom_shipping_fields( $fields ) {
$fields[‘shipping_postcode’][‘maxlength’] = 5;
return $fields;
}
add_filter( ‘woocommerce_shipping_fields’, ‘my_wc_custom_shipping_fields’ );