如何在这种情况下弹出错误提示框

codayssss 2004-10-26 11:24:40
在这个表单下
<form name="form1" method="post" action="">
<input type="text" name="textfield">
 <input type="text" name="textfield1">
<input type="submit" name="Submit" value="提交">
</form>
1。如何在提交时,当"testfield1"为空时,弹出错误提示框,
确认过后继续进行输入,直到按要求提交成功为止。
2。当提交成功后,如何弹出提示框,并清空表单内容。
...全文
133 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
MikeCheers 2004-10-30
  • 打赏
  • 举报
回复
因为前几位的只在当前页面进行了处理,并没有把内容提交出去。
<script language=javascript>
function che(){
if(document.form1.textfieldl.value==""){
alert("输入不完整");
document.form1.textfieldl.focus();
return false;
}
alert("提交成功");
document.form1.reset();
return true;
}
</script>
在这行
<form name="form1" method="post" action="">
改成
<form name="form1" method="post" action="" onsubmit="che();">
这样是不行的,表单还没有提交,就已经清空了。交什么啊?
不过前部分的代码是可以利用的,在当前页面判断文本框是否为空,在接受表单的页面提示提交成功,并返回表单页面就可以了。不用特别为了清空表单而写代码。注意,不要用javascript 的history.back();,那样不会清空表单,要用response.Redirect("表单页面地址")。
hushuang7094 2004-10-30
  • 打赏
  • 举报
回复
<% if request("textfield")="" then
response.write("<script>alert('textfield内容为空,请返回重输!');history.go(-1)</script>")
response.end
end if

if request("textfield1")="" then
response.write("<script>alert('textfield1内容为空,请返回重输!');history.go(-1)</script>")
response.end
end if

……处理提交程序,完毕后

%>
<script>
alert('添加资料成功!');
location.href="add.asp" '再转回初始页,一切ok!
</script>
<%
response.end
%>
cdsun 2004-10-29
  • 打赏
  • 举报
回复
<script language=javascript>
function che(){
if(document.form1.textfieldl.value==""){
alert("输入不完整");
document.form1.textfieldl.focus();
return false;
}
alert("提交成功");
document.form1.reset();
return true;
}
</script>
在这行
<form name="form1" method="post" action="">
改成
<form name="form1" method="post" action="" onsubmit="che();">
yymzzl 2004-10-29
  • 打赏
  • 举报
回复
<td align=right><input type="button" value="登陆" onclick="return CheckLogin(this.form)" >

<script language="javascript">
<!--
function CheckLogin(form){
if(form.username.value==""){
alert("请输入您的用户名!"); return false;
}
if(form.password.value==""){
alert("请输入您的密码!"); return false;
}
form.submit();
return true;
}
-->
</script>
codayssss 2004-10-29
  • 打赏
  • 举报
回复
为什么我不能成功呢?(其它几位的我也试过了,问题出在哪儿?)

<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="" onsubmit= "if(this.testfield1.value==''){alert('请填');return false;}">
<input type="text" name="textfield">
 <input type="text" name="textfield1">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
tutu944 2004-10-26
  • 打赏
  • 举报
回复
cuixiping(无心) ,正解
fluxayxxx 2004-10-26
  • 打赏
  • 举报
回复
up,用javascript写个验证函数
heyixiang 2004-10-26
  • 打赏
  • 举报
回复
<form name="form1" method="post" action="" onsubmit="window.event.returnValue=false;frmSub();">
<input type="text" name="textfield">
 <input type="text" name="textfield1">
<input type="submit" name="Submit" value="提交">
</form>

<script language=javascript>
function frmSub(){
if(this.form.textfield==""){
alert("输入不完整");
this.form.textfield.focus();
}
else if(this.form.textfield1==""){
alert("输入不完整");
this.form.textfield1.focus();
}
else{
this.form.submit();
}
}
</script>
yb2008 2004-10-26
  • 打赏
  • 举报
回复
关注!
chenxuchen 2004-10-26
  • 打赏
  • 举报
回复
<script language=javascript>
function che(){
if(document.form1.textfieldl.value==""){
alert("输入不完整");
document.form1.textfieldl.focus();
return false;
}
alert("提交成功");
document.form1.reset();
return true;
}
</script>
在这行
<form name="form1" method="post" action="">
改成
<form name="form1" method="post" action="" onsubmit="che();">
阿_浩 2004-10-26
  • 打赏
  • 举报
回复
if (document.textfield.textfield.value=="")
{
alert("请填写");
document.textfield.textfield.focus();
return false;
}
cuixiping 2004-10-26
  • 打赏
  • 举报
回复
<form name="form1" method="post" action="" onsubmit="if(this.testfield1.value==''){alert('请填');return false;}">

刚才掉了个括号
cuixiping 2004-10-26
  • 打赏
  • 举报
回复
<form name="form1" method="post" action="" onsubmit="if(this.testfield1.value==''){alert('请填');return false;">

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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