pr.nimbalkar Posted December 16, 2006 Share Posted December 16, 2006 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 More sharing options...
AbstractApproach Posted December 16, 2006 Share Posted December 16, 2006 Mozilla, like most anything else, will use the button of type submit if you hit enter: <input type="password" id="pw"><!--Doesn't work: <input type="button" value="Submit">--><input type="submit" id="btnSubmit" value="Submit"> I'm not sure what it does if you have more than one submit....//Matt Link to comment Share on other sites More sharing options...
jesh Posted December 18, 2006 Share Posted December 18, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now