I am trying to attach the validation on a button click. I have:
<script>
$().ready(function() {
//
$("#btnAdd").click(function() {
$("#myForm").validate({
// $("#crap").rules("add", {required: true, messages: {required:"Required input"} });
rules: { crap: "required" },
messages: { crap: "required field"}
// $("#myForm").validate();
});
});
});
</script>
<form method="post" id="myForm" name="myForm">
<input type="text" name="crap" id="crap" class="required" />
<br />
<input type="button" name="btnAdd" id="btnAdd" value="add" />
</form>
now, if i change btnAdd to a submit type, it works. otherwise, it won't. how can i call the validation on a button click ? thanks