0

This is my code for validating a password through my log-in form. How will I add the special characters as a requirement?

<script>
// validates password
    document.getElementById("confirm_password").disabled = true;
    document.getElementById("initial_pass").onkeyup = function() {
        let password = document.getElementById("initial_pass").value;

        if (password.length > 10 && password.match(/^[0-9a-z]+$/i) && password.match(/\d/) && password.match(/[a-z]/i)){
            document.getElementById("confirm_password").disabled = false;
        }
        else {
            document.getElementById("confirm_password").disabled = true;
        }
    }
</script>
j08691
  • 197,815
  • 30
  • 248
  • 265

0 Answers0