Click to See Complete Forum and Search --> : Check for blank value in form and stop


rmagan
12-06-2007, 10:03 AM
I'm trying to loop thru my form and stop at the first blank value in field 'f03' and set focus. For some reason, its not stopping at the first blank. What am I doing wrong?

for (var i=0; i<document.wwv_flow.f03.length; i++) {
var f03_check = document.wwv_flow.f03[i].value;
var stopit=false;
while (f03_check == '' && stopit == false)
{
stopit = true;
try{
document.wwv_flow.f03[i].focus();
alert(i);
alert(stopit);
}
catch(er){
}
}
}

Fang
12-06-2007, 12:10 PM
var aInput=document.wwv_flow.getElementsByName('f03');
for (var i=0; i<aInput.length; i++) {
if(aInput[i].value==""){
aInput[i].focus();
return;
}
}