var ielems = document.getElementsByTagName('input'); for(var i in ielems){ if(ielems[i].maxLength < 1) ielems[i].style.backgroundColor='blue'; }