The reason that your code was not working is you did not call you function hello at any event.
You should not write as below
<head> <h3> Hello Web</h3> <br> </head>
It should be like
<!DOCTYPE html> <html> <head> <title>Hello World</title> </head> <body> <form id="test-form" action="someurl" method="POST"> <input type="text" name="textvalue" id="textvalue" /> <input type="submit" name="submit" value="SAVE" /> </form> </body> </html>
Below is the solution for your problem.
jQuery(document).ready(function($) { $('#test-form').submit(function(event) { // Prevent form submission event.preventDefault(); alert("Form submission prevented"); var textValue = $('#textvalue').val(); // Alert the value alert("textValue = " + textValue); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form id="test-form" action="someurl" method="POST"> <input type="text" name="textvalue" id="textvalue" /> <input type="submit" name="submit" value="SAVE" /> </form>
why not working...??Please elaborate the details on the issue you are facing.