• Resolved beelt

    (@beelt)


    Hi! Please help.

    I would like to disable ENTER key functionality to use only AJAX search.
    I found examples of JS code here: https://stackoverflow.com/a/11235672

    BUT, I don’t understand which file and where exactly should I put necessary JS code ?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Damian Góra

    (@damian-gora)

    Hi,

    You can paste following code into your functions.php in your child theme.

    
    add_action('wp_footer', 'dgwt_disable_form_submit_on_enter');
    
    function dgwt_disable_form_submit_on_enter(){
        ?>
    <script>
        jQuery('.dgwt-wcas-search-form').on('keyup keypress', function(e) {
            var keyCode = e.keyCode || e.which;
            if (keyCode === 13) {
                e.preventDefault();
                return false;
            }
        });
    </script>
    <?php
    }
    

    If you don’t use child theme, take a look at the article How to Add Code to WordPress Header and Footer?

    In this case you have to only paste code from <script> to </script>

    Best
    Damian Góra

    Thread Starter beelt

    (@beelt)

    Thanks, it works!)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Where to put JS code to disable ENTER key ?’ is closed to new replies.