11-18-2022, 12:39 PM
I'm trying to validate the form. It's validating perfectly but the form is not submitting. In the console, it says that isValid() is not a function
I tried to give a condition that form validates
I tried to give a condition that form validates
Code:
$('#saveStudent').parsley();
Code:
var addvalidation = new JustValidate('#saveStudent');
addvalidation
.addField('#poster', [
{
rule: 'files',
value: {
files: {
extensions: ['jpeg', 'png', 'jpg'],
// maxSize: 25000,
// minSize: 1000,
types: ['image/jpeg', 'image/png', 'image/jpg'],
// names: ['file1.jpeg', 'file2.png'],
},
},
errorMessage: 'Only jpeg, jpg, png formats are supported.',
},
]);
Code:
$(document).on('submit', '#saveStudent', function (e) {
e.preventDefault();
var formData = new FormData(this);
formData.append("save_student", true);
if ($(this).isValid()) {
$.ajax({
type: "POST",
url: "save.php",
data: formData,
processData: false,
contentType: false,
success: function (response) {
$('#addMovie').show();
$('#studentAddModal').modal('hide');
$('#saveStudent')[0].`your text`reset();
$('#myTable').load(location.href + " #myTable");
}
});
}
});