请问这样为什么还会提交?

TaskID 2005-02-21 10:51:16
<html>
<head>
<script language="javascript">
function check()
{
if(document.form1.text1.value=="")
{
alert("null");
return;
}
else
{
document.form1.submit;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>

<form action="test_action.jsp" method="post" name="form1">
<textarea name="text1" cols="" rows=""></textarea>
<input name="test" type="submit" onclick="javascript:check()">
</form>
</body>
</html>


当文本框为空时,有提示,按确定后还是会提交上去
...全文
117 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
平淡面对 2005-02-22
  • 打赏
  • 举报
回复
〉〉〉 return;
换成 return true;
平淡面对 2005-02-22
  • 打赏
  • 举报
回复
〉〉〉 return;
换成 return false;
以梦为马 2005-02-22
  • 打赏
  • 举报
回复

<input name="test" type="submit" onclick="javascript:check()">


"submit">>>"button"


shanzaid 2005-02-22
  • 打赏
  • 举报
回复
<input name="test" type="submit" onclick="javascript:return check()">
換成<input name="test" type="button" onclick="javascript:return check()">
enjoy330 2005-02-22
  • 打赏
  • 举报
回复
<input name="test" type="submit" onclick="javascript:return check()">
icethunder 2005-02-22
  • 打赏
  • 举报
回复
<html>
<head>
<script language="javascript">
function check()
{
if(document.form1.text1.value=="")
{
alert("null");
return false;
}
else
{
document.form1.submit;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>

<form action="test_action.jsp" method="post" name="form1" onsubmit="return check();">
<textarea name="text1" cols="" rows=""></textarea>
<input name="test" type="submit" value="确定">
</form>
</body>
</html>

这么写就好啦,楼主
cosmograd 2005-02-22
  • 打赏
  • 举报
回复
我平时都这么写的:

function check()
{
if(document.form1.text1.value=="")
{
alert("null");
return false;
}
else
{
document.form1.submit;
}
return true;
}


<input name="test" type="submit" onclick="return check();">
thrive_li 2005-02-22
  • 打赏
  • 举报
回复
return false
曼绕木杉 2005-02-22
  • 打赏
  • 举报
回复
<input name="test" type="submit" onclick="javascript:return check()">

function check()
{
if(document.form1.text1.value=="")
{
alert("null");
return false;///////
}
else
{
document.form1.submit;
}
}
lmyabc 2005-02-22
  • 打赏
  • 举报
回复
同意 enjoy330的,嘿嘿
geelpheels 2005-02-22
  • 打赏
  • 举报
回复
"submit">>>"button"

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧