Monday, July 23, 2012

Asp.Net jQuery Textbox keydown event Handler


The keydown event of the TextBox can be handled by tracking the keydown event in jQuery as follows.

Syntax
$("#yourtextbox").keydown(function() {
… 
});

Example
//
// Textbox Event Handler - keydown Event
$('#txtEventHandler').keydown(function(event) {
   alert('Keydown event fired for the key: ' + event.which);
   alert('Textbox Value: ' + $(this).val());
});

<asp:TextBox id="txtEventHandler" runat="server"></asp:TextBox></asp>
Notice that the keydown event delays fetching the value of textbox by the latest 1 character, the keyup event gives the exact value from the textbox.


Search Flipkart Products:
Flipkart.com

No comments: