Showing posts with label Default Action. Show all posts
Showing posts with label Default Action. Show all posts

Wednesday, July 19, 2017

Prevent default form action and do another one

Some time we need to perform an action rather than default form action. For this use the script given below.

 $('#YourformID').on('keyup keypress', function (e) {  
     var keyCode = e.keyCode || e.which;  
     if (keyCode === 13) {  
       e.preventDefault();  
       $(this).find('#YourActionButtonID').click();  
     }  
   });