Hi
I'm new to jquery - I'm successfully using the jquery form plugin, but I want to be able to use jquery validate on the same form. How can I get it so that the form validates before submit?
Here's the jquery form code I'm using:
I've tried adding the script below before the above code, and what happens is it focusses on the field that doesn't validate, but submits the form at the same time.
$(document).ready(function() {
$('.sub_spinner').hide();
var options = {
target: '#output1', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse // post-submit callback
};
$('#myform').ajaxForm(options);
});
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
$('#test_null_submit').hide();
$('.sub_spinner').show();
return true;
}
function showResponse(responseText, statusText) {
$('.sub_spinner').hide();
$('#pfh').hide();
}
And that's where I got stuck. Can anyone tell me how to combine the two so that it validates before it submits?
- $(document).ready(function(){
$("#commentForm").validate(); });
Many thanks