how to check confirm password field in form without reloading page

后端 未结 15 1800
青春惊慌失措
青春惊慌失措 2020-12-12 13:58

I have a project in which I have to add a registration form and I want to to validate that the password and confirm fields are equal without clicking the register button.

15条回答
  •  抹茶落季
    2020-12-12 14:35

    function check() {
        if(document.getElementById('password').value ===
                document.getElementById('confirm_password').value) {
            document.getElementById('message').innerHTML = "match";
        } else {
            document.getElementById('message').innerHTML = "no match";
        }
    }
    
    
    

提交回复
热议问题