How To Activate Numeric Keypad On Woocommerce Checkout Fields For Mobile Users?
Is it possible to activate number keyboard for mobile user in woocommerce checkout?
I have customized woocommerce default checkout fields and some of these fields are just number (for example:Postal code, Phone, etc.).
Most of my website visitors are mobile users and I want to make the checkout session easier for them by activating numeric keypad for these input fields.
I searched the web and I realized if you add below code,numeric keyboard will be called automatically.
<input inputmode="numeric" pattern="[0-9]*">
Finger-friendly numerical inputs with inputmode
But I don't know how can I add this attribute to checkout fields like billing_phone,billing_postcode, or other custom fields which ask for number.
Any help would be appreciated Thanks
Answer
After further research I found a snippet for this question from businessbloomer:
// Change field type to number woocommerce checkout
function bbloomer_change_checkout_field_input_type() {
echo "<script>document.getElementById('billing_postcode').type = 'number';</script>";
echo "<script>document.getElementById('billing_city').type = 'number';</script>";
}
add_action( 'woocommerce_after_checkout_form', 'bbloomer_change_checkout_field_input_type');
Related Questions
- → CORS missmatch because of http
- → Building sitemap for 2 wordpress install under 1 domain
- → How to remove empty elements after class?(jQuery)
- → Get width of an element and apply to another relative to the first one?
- → How to remove caption p class from wordpress?
- → 301 Redirection from no-www to www in wordpress
- → Laravel 5 routing using prefix
- → WordPress - Header position Top, Left &Right
- → how to add rel=nofollow to some specific external links in wordpress
- → octobercms install error: database is not empty?
- → How to edit the index page of wordpress theme?
- → How to select a Post Type (Wordpress) to pass a filter in head?
- → What sort of URL structure should be used to display AMP HTML vs vanilla HTML