Browsers do that by default. They will submit the form you're currently on when you hit enter(unless you're in a textbox) you don't have to do anything special.
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
hi
i think you want that login form submit that user press enter key after entering password right.
so i pu one example here where i call javascript function on keypress of textbox
<input name="login2" type="password" class="form" id="login2" maxlength="30" style="width:180" onKeyPress="return entersubmit(this,event)"/>
<script type="text/javascript">
function entersubmit(field,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
//alert('hi');
if(Email.validate() && Passwd.validate())
{
field.form.action="userlogin";
field.form.submit();
return false;
}
}
else
return true;
}
</script>
Thanks
Tulsa
Junior Poster in Training
77 posts since May 2009
Reputation Points: 13
Solved Threads: 15
hi
Yes
when we click on enter in textbox forms is automatically submitted only in "google chrome" browser
so for i.e and mozila browser we need to use this type of code as per my view..
Thanks
Tulsa
Junior Poster in Training
77 posts since May 2009
Reputation Points: 13
Solved Threads: 15
For automatic submission on enter, I thought you needed a submit button. Perhaps I'm wrong? You seem to have a link. Is this so you can style it with CSS? You can style buttons with CSS too.
The link isn't to ajax, so why are you using a link instead of a button?
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
The input button is hidden because apparently it's still needed (triggered) upon form submit.
I may be a bit slow here (probably!), but why do you need this hidden input anyway? It doesn't seem to do anything, does it?
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080