Home Forums WoodMart support forum Search Button in Mobile Menu Bug

Search Button in Mobile Menu Bug

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #66504

    rmbaumer
    Participant

    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.

    #66522

    Artem Temos
    Keymaster

    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

    #71535

    rmbaumer
    Participant

    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!

    #71596

    Artem Temos
    Keymaster

    Great, we are glad that you found the solution.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Search Button in Mobile Menu Bug’ is closed to new replies.