Posted By

weldonr30 on 06/05/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


Stop Enter key (default submit method) & replace with specified method


 / Published in: jQuery
 

13 is Enter key return false cancels the postback

In this case I am calling the javascript doPostBack and telling it to execute the txtBoxTextChanged method brief tutorial on doPostBack here: http://aspalliance.com/895UnderstandingtheJavaScript___doPostBackFunction.all

  1. //prevent page submit on enter key press
  2. //call the postback javascript then cancel the enter key press
  3. $(document).keydown(function (e) {
  4. if (e.keyCode == 13) {
  5. __doPostBack('txtBox_TextChanged', '');
  6. return false;
  7. }
  8. });

Report this snippet  

You need to login to post a comment.