I'm doing a client side in javascript and html. I have a problem. I want to check if password and repeat password are the same. In that case I want to disable an input. I saw some codes around but I don't understand why it doesn't work. Can you help me? Here is my HTML:
<input class="form-control form-stacked last" name="repeatPassword" id="repeat" placeholder="Repeat password" type="password">
<input class="btn btn-beats btn-block btn-stacked" value="Sign up" onkeydown="enable()" id = "btnPlaceOrder" type="submit">
<input class="form-control form-stacked" name="password" id = "password" placeholder="Password" type="password" required="true">
And then here is my javascript function:
var password = document.getElementById("password");
var repeat = document.getElementById("repeat");
function enable(){
if (password.value() == repeat.value()){
document.getElementById("btnPlaceOrder").disabled = false;
} else{
document.getElementById("btnPlaceOrder").disabled = true;
}
}
Just to be precise, I did the import of the javascript in my HTML
valueis a property, not a method, soif(password.value == repeat.value)onkeydownlistener which responds to the keyboard, not the mouse.