var caps = 0; for(i=0;i<text.length;i++) { if(search_caps(text[i])) caps++; } if(caps > 6) return false;