function Check_FileType(str)
{
var pos = str.lastIndexOf( " . " );
var lastname = str.substring(pos,str.length) //此处文件后缀名也可用数组方式获得str.split(".")
if (lastname.toLowerCase() != " .jpg " && lastname.toLowerCase() != " .gif " )
{
alert( " 您上传的文件类型为 " + lastname + " ,图片必须为.jpg,.gif类型 " );
document.myform.pic.focus();
return false ;
}
else
{
return true ;
}
}
http://www.cnblogs.com/SList/archive/2005/11/09/272164.html