中文字幕在线影院:有关Javascript和浏览器

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 07:45:02
<form action="addpro_ok.asp" method="post" name="newproduct" id="newproduct" onsubmit="return check()">
<script>
function check()
{
username = document.newproduct.name.value;
userclass = document.newproduct.class.value;
userprice = document.newproduct.price.value;
if (username=="")
{
alert("请填写商品名称!");
return false;
}

if (userclass=="0")
{
alert("请选择商品类别!");
return false;
}
if (userprice=="")
{
alert("请填写商品价格!");
return false;
}
}
</script>

……(以下省略)

为什么上面的验证语句在Firefox可以执行,在IE里面就不执行了呢?(我IE的JAVASCRITP未被禁用)

<form action="addpro_ok.asp" method="post" name="newproduct" id="newproduct" onsubmit="return check();"> 分号
<script language="javascript"> 指定语言
function check()
{
val username = document.newproduct.name.value;
val userclass = document.newproduct.class.value;
val userprice = document.newproduct.price.value;
还有name 是关键字 不可以用 改个名字
class不知道是不是 建议也改一下