Tuesday 17 September 2019

javascript - Submit the login on Enter key




I am trying to submit the login on pressing the Enter key, earlier everything was under a form tag so it would work on pressing the Enter key. But now it won't, could someone please give me a fix for this.



HTML:







Answer



Did you try to put a form tag arround it and bind an eventlistener to it:



document.querySelector('.myForm').addEventListener('submit', function(e) {
e.preventDefault();
// do your put request here
}


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...