i'm having this problem with my codes. what im supposed to achieve is to enable a disabled button with a certain condition. my code is working when the condition is invalid, but if its correct it will not work right away. i have to re click it to be enabled. $sentEmailClients (will be a mysql data if i got it working).
Here's my code
<?php
$sentEmailClients = 'test@test.com';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $_POST["validEmail"];
if ($email === $sentEmailClients) {
echo '
<script>
function enableButton2() {
document.getElementById("addToClient").disabled = false;
}
< /script>
';
} else {
echo 'Please enter a valid email';
}
}
and here's the form BTW i've used Bootstrap for this
<form class="form-horizontal" method='post' data-toggle="validator">
<fieldset>
<div >
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Validate My Email!</h4>
</div>
<div class="modal-body">
<label for="validEmail">Email:</label>
<input type="text" class="form-control input-sm " id="validEmail" name = "validEmail" required>
</div>
<div class="modal-footer">
<button class="btn btn-warning btn-lg " id="submit" type="submit text-center" onclick="enableButton2()" >Validate!</button>
<button class="btn btn-success btn-lg " id="addToClient" type="submit text-center" onclick="addClientInformation();" disabled >Submit Information</button>
</div>
</div>
</div>
</div>
</fieldset>
</form>