To validate what the user has entered in a Select field I use this code:
frm=window.document.forms[0];
var idx=frm.DocArea.selectedIndex;
var val=frm.DocArea.options[idx].text;
var tmpVal;
if(idx== -1 || idx==0 )
{
alert(“Please select Area.”);
frm.DocArea.focus();
return false;
}
tmpVal = val
alert(tmpVal)
// f.submit();
As seen elsewhere on this site ![]()
Problem solved. If the user has selected the first entry in the list the idx is zero!
I will correct the code.