A form, I use AJAX to transfer the data. The AJAX is triggered by onClick="", I also use JQuery validate(). JQuery validate() is executed after the onclick=“function()", I would like the JQuery validate() is executed before the onclick="functionname()", how to do it?
<?php $addtext=<<<html
<a id="give_comment" href="javascript:void(0)">Supplement</a>
<div id="comment_text" name="comment_text" style="display:none">
<form id="add_text" action="nofile.php" method="post" onsubmit="return false;">
<textarea id="giver_comment_text" name="giver_comment_text" rows="6" cols="70" class="font1"></textarea><br/>
<input id="giver_submit_comment" type="submit" value="Submit" onclick="validateDetail()" /></form></div>
<br/>
html;
echo $addtext;
?>
Javascript code:
function validateDetail()
{
$('#add_text').validate({
rules:{
giver_comment_text:{
required:true,
minlength:50,
maxlength:600
}
},
});
var detail=$('#giver_comment_text').val();
//$.post(The content of AJAX);
}