In your php code you will create a variable such as $enablesubmit = 'disabled'
and then a php variable for each of the form elements that will be toggled to true
or 1
for each form element that is submitted successfully..
For example, lets say there are 3 form elements with the names inputname
, inputaddress
, inputphone
. You create 3 php variables with the names $binputname
, $binputaddress
, $binputphone
Make sure to place this variable NOT within a function and NOT within the code that runs php code if the form has been submitted $_SERVER["REQUEST_METHOD"] == "POST"
.
In other words $enablesubmit
will be a public PHP variable.
Then within the if($_SERVER["REQUEST_METHOD"] == "POST"){
you would check to see that all the POST form elements meet the conditions in which you would want the submit button to be enabled ...
Then in the form submitted button html code on the web page ...
Now, if the page is loaded and the form data has not been submitted, the default value of the php variable $enablesubmit
equals disabled
. If the form is submitted and the form elements meet the desired condition in the php code at the top of the page, $enablesubmit
equals ''
, meaning disabled
won't get output in the form submit button so the form submit button will now be enabled.