//////////////////////////////////////////
document.addEventListener('DOMContentLoaded', function() {
var form = document.querySelector('form[action="post.php?post=187&action"]');
if (form) {
form.addEventListener('submit', function(event) {
// Prevent default form submission
event.preventDefault();
// Perform form validation
if (validateForm(form)) {
// Submit the form if validation passes
form.submit();
} else {
// Display error message to the user
alert('Please fill out all required fields.');
}
});
}
function validateForm(form) {
// Implement your form validation logic here
// Return true if validation passes, false otherwise
// Example: Check if all required fields are filled out
var requiredFields = form.querySelectorAll('[required]');
for (var i = 0; i < requiredFields.length; i++) {
if (!requiredFields[i].value.trim()) {
return false; // Validation fails if any required field is empty
}
}
return true; // Validation passes if all required fields are filled out
}
});
/////////////////////////////////////////////////////