key up event not work in Firefox when enter key press other browser enter key work

2 posts, 0 answers
  1. M Kumar
    M Kumar avatar
    96 posts
    Member since:
    Apr 2008

    Posted 17 Jan 2019 Link to this post

    Hi,

     

              I put radtextbox on that we put the onkeyup event it work in chrome,ie but not work in Firefox when enter key press but other than enter key it work in firefox.

     

    Example:

     <telerik:RadTextBox ID="mainSearchTxt" onkeyup="mainSearchTxt_keyup(event,id)" EmptyMessage="Content Search"  Width="150px" runat="server"> </telerik:RadTextBox>

    function mainSearchTxt_keyup(e, id) {


        var unicode = e.charCode ? e.charCode : e.which;
        alert(unicode);

    }

    This alert message show in firefox when all keypress except "Enter key" for that i need solution

     

     

     

  2. Vessy
    Admin
    Vessy avatar
    2091 posts

    Posted 22 Jan 2019 Link to this post

    Hi M Kumar,

    By default RadTextBox submits its content when the Enter key is pressed this is why the standard Enter key-up event is not triggered as expected. You can handle the control's client-side KeyPress event, though, and cancel its arguments in case you want to prevent the page submission:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/textbox/client-side-programming/events/onkeypress

    For example:
    <telerik:RadTextBox ID="mainSearchTxt" EmptyMessage="Content Search" Width="150px" runat="server">
        <ClientEvents OnKeyPress="onKeyPress" />
    </telerik:RadTextBox>
    <script>
        function onKeyPress(textBox, args) {
            var unicode = args.get_keyCode();
            if (unicode == 13) {
                alert("Enter");
                args.set_cancel(true);
            }
        }
    </script>



    Regards,
    Vessy
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top