Jump to content

Form submission on 'enter' key press in Mozilla


pr.nimbalkar
 Share

Recommended Posts

Hi friends, i hv 2 textboxes of login & password & submit button. when i put password in textbox & press 'enter' key , the form is not submitted in the mozilla. How do i fix this bug? I used this script :onkeyup event of password textboxfunction setFoc(obj){ var keyValue = obj.keyCode; if(keyValue == 13){ document.getElementById("butLogin").focus(); //document.getElementById("butLogin").click(); // document.form1.submit(); return true; }}

Link to comment
Share on other sites

I can't remember. I generally try to prevent ENTER from submitting the form. However, I believe that if you have more than one form element (i.e. a username and password field) then you'll have to use javascript to submit the form on ENTER. If AbstractApproach's method doesn't do it, try something like this:Javascript

function CheckForEnter(e){	e = (e) ? e : window.event;	var charcode = (e.which) ? e.which : e.keyCode;	if (charcode == 13) // 13 is ENTER	{		// submit the form	}}

HTML:

<input type="text" id="login" value="" /><input type="password" id="password" value="" onkeydown="CheckForEnter(event);" />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...