Possible Duplicate:
submit is not a function in javascript
I am trying to submit form using JS, but no luck. Here is the code. JSFIDDLE
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function validate () {
alert('start');
$('#myform').submit();
alert('end');
}
</script>
</head>
<body>
<form id="myform" name="myform" method="post" action="">
<input type="button" value="submit" id="submit" onclick="validate();" >
</form>
</body>
</html>
The question is “Why its not working?“.
You have an form element with the id
submitwhich conflicts with the form methodsubmit, change the submit button id to something else.You can access form elements as properties of the form object, so if you have a form say myForm and an input in the form with id or name submit then myForm.submit will be the input element with id submit and not the original submit method.
See http://jsfiddle.net/4kg8c/1/