我正在尝试控制密码输入。当它少于 6 个字符时,我禁用按钮并显示错误消息......但我的问题是当密码大于 6 个字符时,消息再次出现并且按钮仍然禁用......我能做什么做?功能如下..请帮帮我
function passcheck() {
var pass = document.getElementById('password1');
var sb = document.getElementById('submit');
if (pass.value.length < 6) {
document.getElementById('error').style.display = 'block';
sb.disabled = true;
} else {
document.getElementById('error').style.display = 'none';
sb.disabled = false;
}
}
HTML:
<input type="password" name="password1" id="password1" class="textinput" style="margin-left: 15%;margin-top: -2.5%;width: 30%" onchange="passcheck()">
<br>
<input type="button" value="Submit" id="submit" onclick="location.href='userlogin.html'" class="button" style=" margin-top: 4%;width: 15%" >
<br>