A standard form is submitted and I want jquery to determine if its valid first, returning true or false (need false to work). But it just goes on to the action page in any case.
HTML:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<link href="user.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.7.min.js"></script>
<script type="text/javascript" language="javascript" src="regValidation.js"></script>
</head>
<body>
<form id="regform" action="BookstorePage.php" method="post">
<label for="f_name">First name</label>
<input type="text" name="f_name" id="REG_FNAME" />
<label for="l_name">Last name</label>
<input type="text" name="l_name" id="REG_LNAME" />
<input id="btnsubmit" type="submit" name="reg_submit" value="Register!" />
</form>
</body>
</html>
Jquery script:
$("#regform").submit(function() {
alert('Handler for .submit() called.');
return false;
});
However; $(window).load(function () {}); does work.
You need use
$(function() { ... }), it will triggered on document ready. Something like: