0
我有一個表單,其中加載頁面時提交按鈕被禁用。當類已被刪除時啓用表單提交按鈕
window.onload=function()
{
document.getElementById('form_submit').disabled = true;
}
當是空的或不正確的字段中輸入以下類添加到輸入字段:
if(document.getElementById('thickness').value == false)
{
document.getElementById('div_thickness').className = "form-group has-warning";
}
else if(document.getElementById('thickness').value > 1 && document.getElementById('thickness').value < 7)
{
document.getElementById('div_thickness').className = "form-group has-success";
}
else
{
document.getElementById('div_thickness').className = "form-group has-error";
}
當所有錯誤或警告類已被刪除提交應再次啓用,但該按鈕住宿禁用。我缺少任何衝突嗎?
if(document.getElementsByClassName('has-error') || document.getElementsByClassName('has-warning'))
{
document.getElementById('form_submit').disabled = true;
}
else
{
document.getElementById('form_submit').disabled = false;
}
感謝您的提示! – Muiter
不客氣:-) –