Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hiii All,

I have tried with onchange and onblur events for calling javascript on TextBox. But I am able to operate any one of the two buttons, either "tab" or "enter", but not both. I need to know which event can be used to make both the buttons work on Textbox with javascript.

Please suggest me on this issue.

Regards,
Posted

1 solution

Use jQuery. Go to jQuery.com and and download the latest version. Include the jQuery javascript in your page and add the following script :

C#
$("#yourtextboxId").keydown(function (event) {
    if ((event.keyCode == '13') ||
        (event.keyCode == '9')){
        // Do something
    }
});


Easy as that!

BTW : Keycode 13 is for the return, and 9 is for the tab key
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900