function checkReq(f) {
var bad = new Array(), msg = '', el, i = 0;
while (el = f.elements[i++]) if (el.optional) continue;
else switch (el.type) {
case 'text' :
case 'textarea' :
if (!el.value || /^\s+$/.test(el.value)) {
bad[bad.length] = el;
break;
}
else el.style.background = 'white';
}
if (bad.length>0) {
for (var j=0; j<bad.length; ++j) {
bad[j].style.background = 'pink';
}
bad[0].focus();
bad[0].select();
return false;
}
return true;
}

function checkform(f) {
if (!checkReq(f)) return false;
return true;
}