non funziona, ho provato a riscriverla cosi ma non funziona lo stesso come mai???

function TrovaEstensione(FILE1)
{
var nomefile = FILE1
nomefile = nomefile.substr(nomefile.lastIndexOf(".")+1);
return nomefile.toLowerCase();
}

function verifica(form) {
if (form.FILE1.value == "") {
alert("Occorre inserire una allegato");
return false;
}
var est = TrovaEstensione(form.FILE1.value)
if(est=='doc' || est=='pdf'){
alert("DOC o PDF")
return false
}
return true;
}