4
I want to apply the css in a form but when I put the inputs inside some div javascript does not work See the code: In case when I type the email and the password was for the button to turn blue enabled.
<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>
<form id="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 on 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 that and fill in the two fields the javascript on the button doesn’t work. Can anyone help me? I need to put these inputs inside their respective Ivs to style the form.
Did you write this code? Do you know what the selector means
#formLog > inputused in jQuery? Maybe it’s worth reading How >, + , ~ selectors work in CSS?– Woss