Skip to content

Instantly share code, notes, and snippets.

@Michaelkodji
Created October 12, 2022 08:12
Show Gist options
  • Save Michaelkodji/63d66bc6cfd40cd97a3838991bb3d5cd to your computer and use it in GitHub Desktop.
Save Michaelkodji/63d66bc6cfd40cd97a3838991bb3d5cd to your computer and use it in GitHub Desktop.
disable enter key to prevent submit form
<!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