Closed Bug 349508 Opened 19 years ago Closed 15 years ago

when there are two buttons on a page and you try to submit by pressing enter only default button event fires

Categories

(Firefox :: General, defect)

1.5.0.x Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: pkacha, Unassigned)

Details

(Keywords: testcase, Whiteboard: [CLOSEME 5-15-2010])

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6 I have a web page which has 3 text boxes and two submit buttons. A text box called search text and related to submit button called search. A username and password text box these two are related to login button. When i run the above code in IE the validation fires properly like when i keep the cursor in search text box and press enter it displays "Please Enter text to search". Similarly when the cursor is kept on the other two boxes and entered is pressed correct message is displayed. But in firefox when u keep cursor in username text box and press enter it is not working. Reproducible: Always Steps to Reproduce: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>EnterKey_Submit</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <script language="javascript" type="text/javascript" src="include/js/EventManager.js"></script> <script language="javascript" type="text/javascript"> function validateLogin() { var ErrMsg = ''; var flag = true; //alert('hello'); if((document.forms[0]._userIdTextBox.value.length==0) || (document.forms[0]._userIdTextBox.value==null) || (document.forms[0]._userIdTextBox.value=='Email Address')) { ErrMsg+="Please Enter E-Mail Address \n"; } else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0]._userIdTextBox.value)==false) { ErrMsg+="Please Enter valid Email Address \n"; } if ((document.forms[0]._passwordTextBox.value.length==0) || (document.forms[0]._passwordTextBox.value==null) || (document.forms[0]._passwordTextBox.value=='Password')) { ErrMsg+="Please Enter your Password \n"; } if (ErrMsg != '') { alert(ErrMsg); flag=false; return flag; } else { flag=true; return flag; } } function checkInput() { var ErrMsg = ''; var flag = true; if ((document.forms[0]._findTextBox.value.length==0) || (document.forms[0]._findTextBox.value==null) || (document.forms[0]._findTextBox.value=='Password')) { ErrMsg+="Please Enter text to search \n"; } if (ErrMsg != '') { alert(ErrMsg); flag=false; return flag; } else { flag=true; return flag; } } function preventDef(event) { event.preventDefault(); } function removeHandler() { document.getElementById("checkbox").removeEventListener("click",preventDef, false); } function BuildOnKeyDownScript(event,btn) { if (document.all) { if (event.keyCode == 13) { //alert('I.E. browser'); event.cancelBubble = true; event.returnValue=false; btn.click(); return false; } } else if (document.getElementById) { if (event.which == 13) { //alert('Firefox browser'); //btn.removeEventListener("submit",preventDef(event), false); //btn.removeEventListener("click",preventDef(event), false); event.preventDefault(); event.stopPropogation(); btn.click(); return false; } } else if(document.layers) { if(event.which == 13) { alert('Netscape browser'); event.cancelBubble = true; event.returnValue=false; btn.click(); return false; } } } </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form name="Form1" method="post" action="Enterkey_Submit.aspx" id="Form1"> <input type="hidden" name="__VIEWSTATE" value="dDwxMjgwMTkzNjQzO3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+O2k8NT47aTw3PjtpPDk+O2k8MTE+O2k8MTM+Oz47bDx0PHA8bDxUZXh0Oz47bDxcZTs+Pjs7Pjt0PHA8O3A8bDxvbmtleWRvd247PjtsPHJldHVybiBCdWlsZE9uS2V5RG93blNjcmlwdChldmVudCwgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ19zZWFyY2hCdXR0b24nKSk7Pj4+Ozs+O3Q8cDw7cDxsPG9uQ2xpY2s7PjtsPGphdmFzY3JpcHQ6cmV0dXJuIGNoZWNrSW5wdXQoKVw7Oz4+Pjs7Pjt0PHA8O3A8bDxvbmtleWRvd247PjtsPHJldHVybiBCdWlsZE9uS2V5RG93blNjcmlwdChldmVudCwgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ19sb2dpbkJ1dHRvbicpKTs+Pj47Oz47dDxwPDtwPGw8b25rZXlkb3duOz47bDxyZXR1cm4gQnVpbGRPbktleURvd25TY3JpcHQoZXZlbnQsIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCdfbG9naW5CdXR0b24nKSk7Pj4+Ozs+O3Q8cDw7cDxsPG9uQ2xpY2s7PjtsPGphdmFzY3JpcHQ6cmV0dXJuIHZhbGlkYXRlTG9naW4oKVw7Oz4+Pjs7Pjs+Pjs+Pjs+ERR+0zOZGsbafdMkpALX/xx2DbQ=" /> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td colspan="3"></td> </tr> <tr> <td> <select name="ddlstIncome" id="ddlstIncome"> <option value="0">--Please Select--</option> <option value="1">Less than $10000</option> <option value="2">$10000 - $ 30000</option> </select> </td> <td> <input name="_findTextBox" type="text" id="_findTextBox" onkeydown="return BuildOnKeyDownScript(event, document.getElementById('_searchButton'))" /> <input type="submit" name="_searchButton" value=">> Search" id="_searchButton" onClick="javascript:return checkInput();" /> </td> </tr> <tr> <td height="20">&nbsp;</td> </tr> <tr> <td colspan="3">LoginId:<br> <input name="_userIdTextBox" type="text" maxlength="15" id="_userIdTextBox" onkeydown="return BuildOnKeyDownScript(event, document.getElementById('_loginButton'))" /> </td> </tr> <tr> <td colspan="3">Password<br> <input name="_passwordTextBox" type="password" maxlength="15" id="_passwordTextBox" onkeydown="return BuildOnKeyDownScript(event, document.getElementById('_loginButton'))" /> </td> </tr> <tr> <td colspan="3"> <input type="submit" name="_loginButton" value=">> Login" id="_loginButton" onClick="javascript:return validateLogin();" /> </td> </tr> </table> </form> </body> </HTML> Expected Results: Please Enter text to search Please Enter E-Mail Address Please Enter your Password I have tried to comment event.preventDefault(); and event.stopPropogation(); but no luck.
Attached file simplified test case
This test case demonstrates the onclick handler of the submit button on a form is fired as part of the form submission. The onkeydown of the input field returns after the form submit is processed due to the alert box that blocks validate_1() until the alert is closed. If the alert is removed or encased in a setTimeout, onkeydown returns false, and the form submit is never processed. In my opinion there are two issues here. The form submit is being processed without waiting for the result of the onkeydown event of the element that triggered it, and submits are performed via the onclick event of the first submit button when it exists. I don't think the submit button itself shouldn't be involved in the form submit, and submits shouldn't be handled by invoking onclick. nsHTMLInputElement::MaybeSubmitForm seems to be what is invoking the submit button onclick. I can understand why this might have been done, however, the form submit button may or may not have anything to do with the form submission itself; the form should be handling the submit and the form elements should not have anything to do with that process.
Keywords: testcase
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → WORKSFORME
pkacha@dreamingcode.com please don't do 'drive-by' WFMs. Care to share what you did to test, what version you tested with, etc? Maybe this is an OS-specific bug; did you test on linux, mac and windows to get to your WFM? Is the testcase wrong?
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
This bug was reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.3 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME http://www.mozilla.com http://support.mozilla.com/kb/Managing+profiles http://support.mozilla.com/kb/Safe+mode
Whiteboard: [CLOSEME 5-15-2010]
Version: unspecified → 1.5.0.x Branch
No reply, INCOMPLETE. Please retest with Firefox 3.6.x or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago15 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: