1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title>Test Case</title> |
---|
5 | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> |
---|
6 | </head> |
---|
7 | <body> |
---|
8 | <form action="#" method="get"> |
---|
9 | <input type="text" name="test" value="Testing..."> |
---|
10 | <input type="submit" value="Submit"> |
---|
11 | </form> |
---|
12 | <script> |
---|
13 | $('form').live('submit', function(event) { |
---|
14 | console.log('canceling form'); |
---|
15 | event.preventDefault(); |
---|
16 | }); |
---|
17 | // Remove the following line to click the submit button, form action is cancelled. |
---|
18 | $('form').submit(); |
---|
19 | </script> |
---|
20 | </body> |
---|
21 | </html> |
---|