Firefox pressing enter bypasses Modal

Last post 07-24-2008 2:59 AM by stmarti. 4 replies.

Sort Posts:

  • Firefox pressing enter bypasses Modal

    07-16-2008, 6:30 AM
    • Loading...
    • plkilroy
    • Joined on 06-15-2003, 10:35 PM
    • Posts 274

    Hi Forum, I have an issue with Firefox1/2 and a Form Validation postback that includes a ModalPopup, pressing the Enter key bypasses the Modal Popup and posts data. (IE works correctly), Any ideas, cheers Paul 

  • Re: Firefox pressing enter bypasses Modal

    07-16-2008, 7:13 AM
    • Loading...
    • stmarti
    • Joined on 06-06-2006, 12:20 PM
    • Posts 706

     If you add UseSubmitBehavior="false" to all asp:button in your form (especially for any button in the modalpopup), the form won't submit by pressing the enter key.

  • Re: Firefox pressing enter bypasses Modal

    07-16-2008, 11:31 PM
    • Loading...
    • plkilroy
    • Joined on 06-15-2003, 10:35 PM
    • Posts 274

    Hi stmarti, thanks for your reply, I tried that but no go, firefox still posts form, not actioning a confirmation modal popup when pressing enter. The script/modal is working on all browsers if user uses submit button. This bug Ive found with firefox/mozilla

    I used your suggestion this way:

    <asp:Button ID="Button" runat="server" Text="Submit" OnClick="Button_OnClick" style="display:none" UseSubmitBehavior="false" />

     

    Much appreciate some advice cheers P 

     

  • Re: Firefox pressing enter bypasses Modal

    07-24-2008, 2:04 AM
    • Loading...
    • plkilroy
    • Joined on 06-15-2003, 10:35 PM
    • Posts 274

    To solve this problem I used some JS, for anyone interested!!

    function stopRKey(evt) {
    var evt  = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text")) { return false; }
    }
    document.onkeypress = stopRKey;

  • Re: Firefox pressing enter bypasses Modal

    07-24-2008, 2:59 AM
    • Loading...
    • stmarti
    • Joined on 06-06-2006, 12:20 PM
    • Posts 706

    plkilroy:
    <asp:Button ID="Button" runat="server" Text="Submit" OnClick="Button_OnClick" style="display:none" UseSubmitBehavior="false" />
     

    It seems yout try to click the button by javascript, and also try to hide the button. 

    But, I think this button not rendered and not part of the DOM at all, because of  style="display:none". This behavior is the standard behavior, so you have problem with firefox.

    You can try instead:

    <div style="display: none"> 

        <asp:Button ID="Button" runat="server" Text="Submit" OnClick="Button_OnClick" UseSubmitBehavior="false" />

    </div> 

    plkilroy:
    To solve this problem I used some JS, for anyone interested!!

    What happens when your user disable javascript? Wink  (considered a malicious user)

     

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter