js.. 这样写怎么没办法执行呀.

来源:百度知道 编辑:UC知道 时间:2024/06/19 18:08:12
<script language="javascript">
function company_reg()
{
if(document.form1.cname.value=="")
{
alert("公司名称不能为空!");
document.form1.cname.focus();
document.form1.cname.select();
return false;
}
document.form1.submit()
}
</script>

表单下面:
onsubmit="return company_reg()"

求救中^^^^^^

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>测试</title>
<script language="javascript">
function company_reg()
{
if(document.form1.cname.value=="")
{
alert("公司名称不能为空!");
document.form1.cname.focus();
document.form1.cname.select();
return false;
}
return true;
}
</script>
</head>

<body>
<form name="form1" method="post" action="to.htm" onsubmit="return company_reg()" >
<p>
<input name="cname" type="text" id="cname">
</p>
<p>
<input type="submit" name="Submit" value="提交" >
</p>
</form>
</body>
</html>