Reputation: 217
This is my AJAX script which I have been using on other pages and it has worked fine.
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery.validate.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#form1").validate({
debug: false,
rules: {
user1: "required",
},
messages: {
user1: "Pick user",
},
submitHandler: function(form) {
// do other stuff for a valid form
$.post('process.php', $("#form1").serialize(), function(data) {
$('#result').html(data);
});
}
});
});
My form below:
<form id="form1" name="form_select" action="process.php" method="post">
<select size="20" name="user1" onChange="this.form.submit()">
<options>...</option>.....
</select>
</form>
Anyone see any reason why this may not work. Been scratching my head for a decent amount of time over this one!
Upvotes: 0
Views: 114
Reputation: 6034
Swap this.form.submit() to jQuery's submit handler
onChange="$(this.form).submit()"
You are calling the DOMs submit() function, not jQuery's submit handler, which your validate plugin is bound to.
Upvotes: 1
Reputation: 3306
I know zilch about jQuery, bur shouldn't the submitHandler
return false
so the form doesn't does a Web 1.0 submit?
Upvotes: 0