摩拳擦掌造句:js 验证上传文件格式
来源:百度文库 编辑:偶看新闻 时间:2024/04/28 21:05:42
function yanzheng2()
{
var a=document.getElementById("TextBox1");
if(a.value=="")
{
alert('请输入购买个数!');
a.focus();
return false;
}
var b=document.getElementById("FileUpload1");
if(b.value=="")
{
alert('请选择上传图片!');
b.focus();
return false;
}
else
{
var FileName=new String(b.value);//文件名
var extension=new String (FileName.substring(FileName.lastIndexOf(".")+1,FileName.length));//文件扩展名
if(extension=="jpg"||extension=="gif"||extension=="jpeg"||extension=="bmp")
{}
else
{
alert('产品图片格式不支持!');
return false;
}
}
var c=document.getElementById("xieyi");
if(c.checked==false)
{
alert('请查看并同意购买协议!');
c.focus();
return false;
}
return true;
}
onclick="Button1_Click" />