-1

JQuery - prevent form submitting on enter button with out prevent the keystroke

$('.filters').keypress(function(event)
{
    if(event.keyCode === 13) 
    {
            $.fn.yiiGridView.update('lead-category-grid', {
                   data: $(this).serialize()
            });
       return false;
    }
});

since this function will prevent the enter keystroke. but i need some function to execute but form should not submitted

22francis
  • 509
  • 4
  • 14

1 Answers1

2
$('.filters').keypress(function(event)
{
    if(event.keyCode === 13) 
    {
       // .... execute your functions here....
       return false;
    }
});
Ibu
  • 42,752
  • 13
  • 76
  • 103
  • if i put jquery function there will it work for me its not working.. – 22francis Jul 23 '12 at 19:10
  • 1
    have you tried putting it there? – Ibu Jul 23 '12 at 19:20
  • i did try using function before `return false;`. but i didn't get answer the problem is with yii framework. from here http://www.yiiframework.com/forum/index.php?/topic/22996-avoiding-form-submission-on-enter-in-a-cgridview-filter-field/ i got patch and updated framework now its working. anyway `@ibu` thanks for your time. – 22francis Jul 23 '12 at 20:15