当输入值为空时,我尝试 setCustomValidity,它正在工作,但问题是错误弹出窗口不断显示消息(当输入处于焦点时)...
function chec() {
inn = document.getElementById('num');
if (inn.value == "") {
inn.setCustomValidity("Empty");
} else {
inn.setCustomValidity("");
}
}
<form>
<input type="number" id="num" min="20" max="50" required>
<input type="submit" onclick="chec()">
</form>
肥皂起泡泡
相关分类