给你下面个代码吧.
//============================判断上传文件扩展名====================================
function FilterType(obj)
{
    //文件名,取得文件的扩展名
    var reg=/([^.]+)$/.exec(obj.value);
    sType = RegExp.$1;
    if(!/(jpg|gif|bmp)$/ig.test(sType))
    {   
        alert("请选择bmp,jpg,gif文件!");
        obj.select();
        document.execCommand("delete");
    }
}