Javascript login form doesn't submit when user hits Enter

后端 未结 7 1552
独厮守ぢ
独厮守ぢ 2020-12-31 10:06

I\'m working on a simple javascript login for a site, and have come up with this:

Login to view!
7条回答
  •  伪装坚强ぢ
    2020-12-31 10:52

    My Thought = Massive security hole. Anyone can view the username and password.

    More relevant to your question: - You have two events happening.

    1. User clicks button.
    2. User presses enter.

    The enter key submits the form, but does not click the button.

    By placing your code in the onsubmit method of the form the code will run when the form is submitted. By changing the input type of the button to submit, the button will submit the form in the same way that the enter button does.

    Your code will then run for both events.

提交回复
热议问题