This is a migrated thread and some comments may be shown as answers.

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

1 Answer 433 Views
Input
This is a migrated thread and some comments may be shown as answers.
M Kumar
Top achievements
Rank 1
Iron
Veteran
M Kumar asked on 18 Jan 2019, 05:54 AM

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

 

 

 

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 22 Jan 2019, 03:23 PM
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.
Tags
Input
Asked by
M Kumar
Top achievements
Rank 1
Iron
Veteran
Answers by
Vessy
Telerik team
Share this question
or