i try to validate the form before submitting the request.
i am using jquery validation
i am expecting when page finish load, the form will auto submit, and i will see “Loading” in the div.
but nothing happen
here is my code. but seems it is not working..
<script type="text/javascript">
function submitForm() {
$('#SearchForm').validate({
errorLabelContainer: "#ErrorLabel",
rules: {
instrument: {
required: true,
maxlength: 10
}
},
messages: {
maxlength: "Must no longer than 10 characters",
required: "Must not be empty"
},
submitHandler: function () { $('#SearchForm').submit(); }
});
}
$(document).ready(function () {
$('#SearchForm').submit(function () {
$('#DivToUpdate').text('Loading ...');
});
submitForm();
});
</script>
ll
Made a small Working demo http://jsfiddle.net/CRfuZ/
2 things: try putting
invalidHandlerand passformto thesubmitHandlerIn the demo above if you will enter more then
maxlenght 10the halbert ininvalidHandlerwill capture it.Rest feel free to play around with the demo.
This will help hopefully 🙂
link: http://docs.jquery.com/Plugins/Validation/validate
COde