$("#da-ex-validate2").validate({
rules: {
details: {
required: true,
rangelength: [1, 500]
},
editor1: {
required: true,
minlength: 1
},
title: {
required: true,
rangelength: [1, 100]
},
SlideDeckPhoto: {
required: "#iButton:checked",
accept: ['.jpeg', '.png', '.jpg', '.gif']
},
min1: {
required: true,
digits: true,
min: 5
},
max1: {
required: true,
digits: true,
max: 5
},
submitHandler: function(form) {
$(form).ajaxSubmit();
},
range1: {
required: true,
digits: true,
range: [5, 10]
}
},
invalidHandler: function (form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
var message = errors == 1
? 'You missed 1 field. It has been highlighted'
: 'You missed ' + errors + ' fields. They have been highlighted';
$("#da-ex-val2-error").html(message).show();
} else {
$("#da-ex-val2-error").hide(); // it's not work !!! and the page is reload !!
}
}
});
I would also would like to save my form values to MySql without reload the page . Please help ! I read so many post and tried so many thing ! If you put a code please tell where to put it .. BTW my form has few input fields and also an file input field . PLEASE HELP !
return false from the submit handler
submitHandler: function(form) {
$(form).ajaxSubmit();
return false;
}
This is my solution, put it after invalidHandler :
submitHandler: function(form) {
var dataString = $('#YourFormID').serialize();
$.ajax({
type: 'POST',
url: 'yourpage.php',
data: dataString,
success: function() {
$('#YourErrorDivID').hide();
$('#YourSuccessDivID').html("Your Message").show();
}
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.