Answers for "prevent enter on input field"

6

html disable enter submit

//per form disabling
<form ... onkeydown="return event.key != 'Enter';">
 
  
//or with jquery  
<script>
 $(document).on("keydown", "form", function(event) { 
    return event.key != "Enter";
});
 </script>
Posted by: Guest on August-26-2020
0

deactivate enter key button

/**
 * Disable the enter key from submitting the form for all forms all fields
 */
<script type="text/javascript">
    jQuery(function($){
        $("form").keypress(function(e) {
          //Enter key
          if (e.which == 13) {
            return false;
          }
        });        
	});
</script>
Posted by: Guest on September-03-2021
0

prevent form submission on enter key

<form action="...">
  <!-- Prevent implicit submission of the form -->
  <button type="submit" disabled style="display: none" aria-hidden="true"></button>

  <!-- ... -->

  <button type="submit">Submit</button>
</form>
Posted by: Guest on May-08-2021

Code answers related to "prevent enter on input field"

Browse Popular Code Answers by Language