javascript key pressed enter
$('.container').on('keydown', 'input', function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopImmediatePropagation();
//Do your stuff...
}
});
javascript key pressed enter
$('.container').on('keydown', 'input', function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopImmediatePropagation();
//Do your stuff...
}
});
html button press enter off
Explicit Prevention:
<form>
<label for="name">Name:</label>
//Not able to press `Enter`
<input type="text" name="name" onkeypress="ExplicitPrevention(event)">
//Able to press `Enter`
<input type="submit" value="Submit">
</form>
<script>
const ExplicitPrevention = function (event) {
var keyPressed = event.keyCode || event.which;
if (keyPressed === 13) {
alert("Test: You pressed the Enter key!!");
event.preventDefault();
}
}
</script>
//Also check: https://www.tjvantoll.com/2013/01/01/enter-should-submit-forms-stop-messing-with-that/
//and: https://www.geeksforgeeks.org/how-to-disable-form-submit-on-enter-button-using-jquery/
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us