Search Button in Mobile Menu Bug
-
Is is possible to make the search button in the mobile menu (magnifying glass) not submit the form if the search form is empty? It causes a page load and leads to an empty search – which on a mobile device with a slow connection is a frustrating experience. Would be great if it could either, do nothing, or do a js prompt for “please enter a search phrase” or similar.
Hello,
Sorry, but there is no such option in our theme at the moment. We will consider adding this feature in our future updates.
Regards
For now, I have addressed this issue by adding the following code to functions.php which makes the search input a required field:
/**
*
* In mobile menu, disable search submit button if search field is empty
*
*/
add_action('wp_footer', 'rmb_disable_empty_mobile_search');
function rmb_disable_empty_mobile_search(){
?>
<script>
jQuery(document).ready(function($){
$('form.searchform input.s').prop('required',true);
});
</script>
<?php
}
In a future release, it would great if you could just add the property required
to the search input itself.
Thanks!
Great, we are glad that you found the solution.
The topic ‘Search Button in Mobile Menu Bug’ is closed to new replies.