sumbit提交表单
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function checkForm()
{
if(document.form1.userName.value.length==0)
{
alert("请输入用户名!");
return false;
}
return true;
document.form1.submit();
}
</script>
</head>
<body>
<form name="form1" method="post" action="ygdacx.html" οnsubmit="return checkForm()">
<input type="text" name="userName" size="10" />
<input type="submit" value="提 交" />
</form>
</body>
</html>
button提交表单
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function checkForm()
{
if(document.form1.userName.value.length==0)
{
alert("请输入用户名!");
return false;
}
document.form1.action ="ygdacx.html";
document.form1.submit();
}
</script>
</head>
<body>
<form name="form1" method="post">
<input type="text" name="userName" size="10" />
<!--<input type="submit" value="提 交" /> -->
<input type="button" value="提 交" οnclick="checkForm()" />
</form>
</body>