validate and submit form when enter is pressed in input(textbox) field but does not select history when enter pressed
<p>similar to how we have  onfocus and onclick on input tags I am using the below method( if the method is wrong please let me know what would be the proper method ) for submitting a form when someone presses enter on a textbox in a field in a form </p>

<p>Example when someone writes the password in the password field and presses enter (when the cursor is on the password field) the form should submit.</p>

<p>I even have a submit button but I want the same thing to happen when text has enter pressed when submit is clicked</p>

<p>I am using this right now   </p>

<pre><code>onkeypress='if (event.keyCode == 13) { validate(); }'
</code></pre>

<p>for my textbox fields</p>

<p>the issue over here is that when the history of my text box shows below my text box and I select it by pressing enter it does not take the value first in my text box. It straight away validates the value in the text box </p>

<p>Example:
I have typed abcin my email textbox, I get abc@xyz.com below my text box showing that I had typed that earlier, not when I do down by pressing the down arrow and pressing enter it does not take abc@xyz.com in my text box but straight away runs validate() anhd gives me an error as wrong email format.</p>

<p>I believe it should first take my old value in the text box and then run the validate function</p>

<p>I am using codeigniter</p>
