I’m using WooCommerce product search widget and add minlength="17"
fragment in this code:
<form role="search" method="get" class="woocommerce-product-search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="screen-reader-text" for="s"><?php _e( 'Search for:', 'woocommerce' ); ?></label>
<input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search Products…', 'placeholder', 'woocommerce' ); ?>" value="<?php echo get_search_query(); ?>" minlength="17" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label', 'woocommerce' ); ?>" />
<input type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woocommerce' ); ?>" />
<input type="hidden" name="post_type" value="product" />
</form>
And it works very nice in Chrome. It shows a message:
“Please lengthen this text to 17 characters or more(You are currently
use * characters)”.
This is what I need, but it doesn’t in Firefox and IE.
When I put 3,4 or less then 17 characters in search field, It starts search.
What to do? How to make it working in all browsers?!
check this out.
DEMO
You can do it with javascript code
Try to implement this snippet, i hope this code will help