I am seeking assistance in using JavaScript to validate a form. When the code outlined below runs successfully, I would like to trigger an external PHP script without reloading the page, followed by displaying a success message. Can anyone provide guidance on achieving this?
The following script effectively retrieves the notEmpty function from a separate source. I require the script to: 1. Execute the PHP and transfer data from listed values if no errors occur. 2. Show a success message upon completion.
var year = document.getElementById('year');
var period = document.getElementById('period');
var live = document.getElementById('live');
var start = document.getElementById('start');
var todate = document.getElementById('todate');
var sdeadline = document.getElementById('sdeadline');
var cdeadline = document.getElementById('cdeadline');
var circ = document.getElementById('circ');
var line = document.getElementById('line');
// Check each input following the form order!
if(notEmpty(year, "Please fill in Year")){
if(notEmpty(period, "Please fill in Period")){
if(notEmpty(live, "Please fill in Live Date")){
if(notEmpty(start, "Please fill in Start Date")){
if(notEmpty(todate, "Please fill in End Date")){
if(notEmpty(sdeadline, "Please fill in Supplier Deadline")){
if(notEmpty(cdeadline, "Please fill in Commercial Deadline")){
if(notEmpty(circ, "Please fill in Circulars Due")){
if(notEmpty(line, "Please fill in Line Listing Downloads")){
}
}
}
}
}
}
}
}
}
return false;