Prevent form submission on Enter key press

前端 未结 19 2346
失恋的感觉
失恋的感觉 2020-11-22 04:18

I have a form with two text boxes, one select drop down and one radio button. When the enter key is pressed, I want

19条回答
  •  感动是毒
    2020-11-22 05:08

    Here is how you can do it using JavaScript:

    //in your **popup.js** file just use this function 
    
        var input = document.getElementById("textSearch");
        input.addEventListener("keyup", function(event) {
            event.preventDefault();
            if (event.keyCode === 13) {
                alert("yes it works,I'm happy ");
            }
        });
    
     
        
          
             
              
          
        

提交回复
热议问题