Created
October 12, 2022 08:12
-
-
Save Michaelkodji/63d66bc6cfd40cd97a3838991bb3d5cd to your computer and use it in GitHub Desktop.
disable enter key to prevent submit form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<form id="myForm"> | |
<input type="email" name="mail"> | |
<input type="password" name="passwd"> | |
<input type="submit" name="btn"> | |
</form> | |
<script type="text/javascript"> | |
myForm.addEventListener("keydown", function(e){if (e.keyCode==13) e.preventDefault()} ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment