How to enter the submit button on the form

I have a form to enter my site. I need to make the form submit when a user logs into the game. How can i do this? Please provide a code. Thank.

          <form id="login" action="myHome.php" method="POST">
            <input type="text" name="email" id="email"/>
            <br/>
            <br/>
            <input type="text" name="password" id="password"/>
          </form>
+5
source share
3 answers

Have you tried anything?

You need to add <input type="submit">and hide it using CSS so that the browser knows that it needs to be launched when the button is clicked, but still does not display the button. For the sake of accessibility and ease of use, I would press a button, even if it is not the way many people use it (input is much nicer).

+7
source

keydown keycode == 13. , ,

function addInputSubmitEvent(form, input) {
    input.onkeydown = function(e) {
        e = e || window.event;
        if (e.keyCode == 13) {
            form.submit();
            return false;
        }
    };
}
+5

This should happen by default. In my experience, some browsers require a field <input type=submit>, but this is usually not a requirement.

0
source

All Articles