Hi friends,
I have 2 different scripts, one is jquery post for form, and second is jquery form validation.
I run post script at submit button click action, so it takes effect before validation :/ and i could not change validation to run before post script :( so now it form submitting without validating.
How can make it? Appreciate helps!
JQuery POST code
$(function() {
$("#btnsend").click(function() {
var dataString = 'fullname='+ escape(document.contact.full_name.value);
$.ajax({
type: "POST",
url: "query.php?act=sendMail",
data: dataString,
success: function() {
$('#contact-form').hide()
.html("<p>thanks!</p>")
.fadeIn(500, function() {$('#contact-form').append("");});
}
});
return false;
});
});
JQuery Validation
thanks for plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/
<!-- Form Validation -->
<script src="inc/validation/jquery.validate.js" type="text/javascript"></script>
<script src="inc/validation/js/cmxforms.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="inc/validation/css/validation.css" media="screen" />
<script type="text/javascript">
$(document).ready(function() {
$("#commentForm").validate();
});
</script>
Form
<form id="commentForm" name="contact" method="post" action="">
<ul id="contact-form">
<li><label for="full_name">Full Name: *</label><input type="text" name="full_name" id="full_name" class="txt_input required" /></li>
<li class="alignRight"><input type="submit" value="Send" id="btnsend" name="btnsend" class="btn_submit" /></li>
</ul>
</form>