My current regex is /^[A-Za-z0-9_-]\w{5,23}$/
and it matches everything but the hyphen. I tried \-
and still no soup. Anybody with a little more experience know how to catch the hyphen?
let errmsg = document.querySelector("#error");
let input_box = document.querySelector("#password");
function checkPassword(value) {
var regex = /^[A-Za-z0-9_-]\w{5,23}$/;
if (!regex.test(value.target.value))
{
console.log(value.target.value);
errmsg.style.display = 'block';
input_box.style.borderColor = 'red';
}
else
{
errmsg.style.display = 'none';
input_box.style.borderColor = 'black';
}
}
input_box.addEventListener('input', checkPassword);