The following works perfectly fine on FF and Chrome. What is IE8 complaining about?
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js" type="text/javascript"></script>
</head>
<body>
<form action="http://www.thisurlisfake.com" id="myForm" method="post">
<input type="text" id="myText" class="required" />
<input type="submit" id="submit" name="submit" />
</form>
<script language="javascript" type="text/javascript">
jQuery(document).ready(function () {
jQuery("#myForm").validate(
{
submitHandler: function (form) {
form.Submit();
}
});
})
</script>
</body>
</html>
If you do NOT input anything into the textbox the JQuery Validation works and displays a warning message.
If you DO put something into the textbox the JQuery Validation succeeds and calls my submitHandler code. Obviously I've removed all my extra logic but basically at the end its suppose to call form.Submit().
HOWEVER, this line "form.Submit();" generates "Error: Object doesn't support this property or method"
I don't know exactly what are you trying to do, but to submit a form, you have to do something like:
or
in the {...} part you validate, whatever you have to validate and if sucess, you do the ajax request:
I can't see how that would work in any browser. There is no
Submit
method. Javascript is case sensetive. Usesubmit
instead.change
ID
andname
of the submit-Button.From the docs:
Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures.