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

RadNumericTextBox > OnKeyPress > set_keyCode?

3 Answers 172 Views
Input
This is a migrated thread and some comments may be shown as answers.
Nelson
Top achievements
Rank 1
Nelson asked on 02 Sep 2013, 03:17 AM
Hi,

I would like to capture the "Enter" keypress and move the control from one "RadNumericTextBox" to "RadNumericTextBox",  is set_keycode not working? The code stop at the set_keycode in the javascript function call.

Cheers, 
Nelson

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Sep 2013, 05:38 AM
Hi Nelson,

Please have a look at the following code I tried which works fine at my end.

ASPX:
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" onKeyDown="checkEnter()">
</telerik:RadNumericTextBox>
<br />
<telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server" onKeyDown="checkEnter()">
</telerik:RadNumericTextBox>
<br />
<telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" onKeyDown="checkEnter()">
</telerik:RadNumericTextBox>

JavaScript:
<script type="text/javascript">
    function checkEnter() {
        if (event.keyCode == 13) {
            event.keyCode = 9;
        }
    }
</script>

Thanks,
Shinu.
0
Nelson
Top achievements
Rank 1
answered on 02 Sep 2013, 05:45 AM
Thanks Shinu. But what i want is when user press "Enter" in the textbox control, the system will move the focus to the next one just like pressing the "Tab". Is it possible?

<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" onKeyDown="MoveNext(this,event)">
</telerik:RadNumericTextBox>
<br />
<telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server" onKeyDown="MoveNext(this,event)">
</telerik:RadNumericTextBox>
<br />
<telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" onKeyDown="MoveNext(this,event)">
</telerik:RadNumericTextBox>


        <script type="text/javascript">
            function MoveNext(sender, args) {
                
                //alert(args);
                var key = args.get_keyCode();
                alert(key);
                if (args.get_keyCode() == 13) {
                    args.set_cancel(true);
                    alert('a');
                    args.set_keyCode() = 9;
                    alert('b');
                }
                
            }
        </script>
0
Shinu
Top achievements
Rank 2
answered on 03 Sep 2013, 09:37 AM
Hi Nelson,

You cannot retrieve the key code using get_keyCode() since the args does not have one such JavaScript method. You can always use the event.keyCode always returns the key code of the current pressed key. Please try the code I posted in my previous reply which works fine for your scenario.

Thanks,
Shinu.
Tags
Input
Asked by
Nelson
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nelson
Top achievements
Rank 1
Share this question
or