Search code examples
javascriptpostauthenticationcharacteronkeydown

How to submit a form OnKeyPress with Javascript?


I want to make a form like this, and i want to post the form - with javascript - in all the keydowns.

<form action="{$formaction}" enctype="multipart/form-data" method="post">
<input type="text" name="n">
<input type="password" name="pw">
<button name="in" type="submit">enter</button>
</form>

please tell me how to do this.


Solution

  • <form onkeydown="this.submit();">
      <!-- form content -->
    </form>