prevent default on enter press
/* Jquery method */
$('#form-input').on('keypress', (e) => {
const keyPressed = e.keyCode || e.which;
if (keyPressed === 13) {
e.preventDefault();
return false;
}
/* or */
return keyPressed !== 13;
});
/* or */
$('#form-input').on('keypress', (e) => return e.keyCode !== 13);
/* HTML Inline */
<form ... onkeydown="return event.keyCode !== 13;">
Also in JavaScript:
- node js favicon.ico
- install vue-cli
- javascript get 24 hour time
- react dropdown menu stack overflow
- how to create array in javascript
- navigating programatically react
- javascript loop object
- angular input press enter
- Discord.js Basics
- javascript ceiling
- moment duratuion from hours
- jquery AND operation
- make object readonly javascript
- string to boolean javascript
- javascript map function
- create array javascript fill
- js import and export
- document jquery
- how run dockerfile
- nodejs include json file
- js array of strings mongoose
- get execution time in javascript
- route react
- hide checkbox jquery