I have a webpage with 20 forms on it.
They are all hidden until you select a form from the drop down box and then the form will appear.
Each form has its own validation. The problem is I’ve included the validation for each form in its own div with each specific form.
So I thought because each div was hidden the validation for all other hidden forms won’t work … How wrong was I 😐
Any way to only include the php file include when the div is not hidden?
Short answer: the web does not work that way.
Longer answer: The browser doesn’t include PHP, the server includes it and spits out all the output in HTML to the browser. The browser just sees the HTML output so it sees and sends everything.
There are a couple of solutions. I would recommend making sure each of your divs has it’s own form tag and then adding a hidden input to each one so that your PHP script can decide what validation it’s supposed to do. Something like this:
Then in PHP:
Hope that helps.