I want to apply the css in a form but when I put the inputs inside some div the javascript does not work See the code: In case when I type the email and the password was for the blue button to be activated.
<style>
.btnDisabled{
pointer-events:none;
outline:none;
border: none;
background: gray;
}
.btnEnabled{
outline:none;
border: none;
background: blue; color: white;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script><formid="formLog" method="post" action="website/login">
<input type="text" id="txtELog" name="txtELog" placeholder="Userlogin ou E-mail: *" />
<input type="password" id="txtPassLog" name="txtPassLog" placeholder="Senha: *" />
<input type="submit" id="btnLog" name="btnLog" value="Login" disabled="disabled" class="btnDisabled" />
</form>
<script>
$ (' #formLog > input').on('input', function () {
var emptyLog = false;
$('form > input, form > select').each(function () {
if ($('#txtELog').val() == '' || $('#txtPassLog').val() == '') {
emptyLog = true;
}
});
if (emptyLog) {
$('#btnLog').attr('disabled', 'disabled');
$('#btnLog').attr('class', 'btnDisabled');
} else {
$('#btnLog').removeAttr('disabled');
$('#btnLog').attr('class', 'btnEnabled');
}
});
</script>
I want to do this in the form:
<form id="formLog" method="post" action="website/login">
<div class="inputText">< input type="text" id="txtELog" name="txtELog" placeholder="Userlogin ou E-mail: *" /></div>
<div class="inputText">< input type="password" id="txtPassLog" name="txtPassLog" placeholder="Senha: *" /></div>
<div class="inputButton">< input type="submit" id="btnLog" name="btnLog" value="Login" disabled="disabled" class="btnDisabled" /></div>
</form>
But when I do this and fill in both fields the javascript of activating the button does not work. Can someone help me? I need to put these inputs inside their respective divs to stylize the form.