Please help, I can't figure it out. You need to do all this on jQuery))

There is a form consisting of two input:

input [name = "password"] and input [name = "confirm_password"]

And there are elements with the classes "length" and "match".

It is necessary to make it so that when entering from the keyboard, checks are done:

1) input [name = "password"]> = 8 characters (if the condition is true, then assign the class "done" to "length")

2) The two inputs are equal to each other (if the condition is true, then assign the class "done" to "match")

    1 answer 1

    Well, as a simple example, you can do this:

    function countCharPass(val){ var leng = val.value.length; if(leng >= 8){ $('.length').addClass('done'); console.log('length done'); }else{ $('.length').removeClass('done'); console.log('length error'); } if($('input[name="password"]').val().trim() === $('input[name="confirm_password"]').val().trim() ){ $('.match').addClass('done'); console.log('match done'); } else{ $('.match').removeClass('done'); console.log('match error'); } } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <p class="length"></p> <p class="match"></p> <input type="password" name="password" onkeyup="countCharPass(this)"> <input type="password" name="confirm_password" onkeyup="countCharPass(this)">