有个关于对话框的小问题。请进来看看

humin1906 2003-09-24 04:35:55
这是我在程序里加的代码。我写的是一个注册的表格
if () then
else
Response.Write("<script language=javascript>window.alert('密码输入前后不一致!')</script>")
end if
运行后。当输入密码不一样时弹出对话框,但是对话框不是在本页面跳出。而且按下确定后,表格里填写的内容全都刷新了,我不要刷新。怎么办啊!!望各位指点迷津
...全文
40 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dicklee1214 2003-09-24
  • 打赏
  • 举报
回复
<form name="theForm" id="theForm" method="post" target="_hideFrame" action="edit_xyman.submit.asp" onsubmit="return CheckData()">


function CheckData()
{

if (changedate(document.theForm .b_fasj.value)>changedate(document.theForm .e_fasj.value)){alert("发案时间终止不能在发案时间初始之前");return false;}
if (changedate(document.theForm .b_fasj.value)==changedate(document.theForm .e_fasj.value))
{
var begintime,endtime
begintime=tostr(document.theForm .b_hour .value) + ':' + tostr(document.theForm .b_min .value) + ':' + tostr(document.theForm .b_sec .value);
endtime=tostr(document.theForm .e_hour .value) + ':' + tostr(document.theForm .e_min .value) + ':' + tostr(document.theForm .e_sec .value);
if (begintime > endtime) {alert("发案时间终止不能在发案时间初始之前");return false}
}
if (changedate(document.theForm .b_fasj.value)>changedate(document.theForm .basj.value)){alert("发案时间不能在报案时间之前");return false;}
if (changedate(document.theForm .b_fasj.value)==changedate(document.theForm .basj.value))
{
var begintime,endtime
begintime=tostr(document.theForm .b_hour .value) + ':' + tostr(document.theForm .b_min .value) + ':' + tostr(document.theForm .b_sec .value);
endtime=tostr(document.theForm .bahour .value) + ':' + tostr(document.theForm .bamin .value) + ':' + tostr(document.theForm .basec .value);
if (begintime > endtime) {alert("发案时间不能在报案时间之前");return false}
}
theForm.btnadd0.disabled=true
theForm.btnadd1.disabled=true
document.all.uploadstate.innerHTML="<div style='position:absolute;border:4px groove pink'><font size=2 color=red>正在保存数据,请稍等....</font></div>"
return true;
}
dicklee1214 2003-09-24
  • 打赏
  • 举报
回复
在form 中<form onsubmit="checkdata ()">控制
这样完全是客户端行为,就会在本页弹处,而且一但谈出后,你给它个return false;
就不会刷新而丢失数据
dicklee1214 2003-09-24
  • 打赏
  • 举报
回复
在form 中<form onsubmit="checkdata ()">控制
这样完全是客户端行为,就会在本页弹处,而且一但谈出后,你给它个return false;
就不会刷新而丢失数据
humin1906 2003-09-24
  • 打赏
  • 举报
回复
快乐宝贝:你的这段代码:
if(object.u_email.value.search("@")!=0 || object.u_email.value.search(".")!=0)
{
object.u_email.focus();
object.u_email.select();
alert("不是合法的Email地址,请准确填写Email地址!");
return false;
}
好象有点问题。我输入正确的地址也是报错的!麻烦你和各位看一下,非常感谢!!
wangjsxz 2003-09-24
  • 打赏
  • 举报
回复
<script language="JavaScript">
function check(object)
{
if (object.u_name.value.length<1)
{
object.u_name.focus();
object.u_name.select();
alert("用户名不能为空!");
return false;
}
if(object.u_pwd.value.length<6)
{
object.u_pwd.focus();
object.u_pwd.select();
alert("请正确输入密码,密码不得少于6位!");
return false;
}
if (object.u_email.value.length==0)
{
object.u_email.focus();
object.u_email.select();
alert("请您输入email地址!");
return false;
}
if(object.u_email.value.search("@")!=0 || object.u_email.value.search(".")!=0)
{
object.u_email.focus();
object.u_email.select();
alert("不是合法的Email地址,请准确填写Email地址!");
return false;
}
if(object.u_tel.value.length<7 || object.u_tel.value.length>12)
{
object.u_tel.focus();
object.u_tel.select();
alert("请正确填写联系方式!");
return false;
}
}
</script>
<table width="335" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#6699FF">
<form action="user_reg.asp" method="post" name="theform" id="theform" onSubmit="return check(this);">
<input type="hidden" name="step">
<tr>
<td height="25" bgcolor="#6699FF"><font color="#FFFFFF">用户注册>></font></td>
</tr>
<tr>
<td><table width="335" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#eeeeee">
<tr bgcolor="#FFFFFF">
<td width="94" height="20"> 用户名</td>
<td width="241"><input name="u_name" type="text" id="u_name" class="tx"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> 密码</td>
<td><input name="u_pwd" type="text" id="u_pwd" class="tx"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> 密码提示问题</td>
<td><input name="u_question" type="text" id="u_question" class="tx"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> 密码提示答案</td>
<td><input name="u_answer" type="text" id="u_answer" class="tx"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> 邮件地址</td>
<td><input name="u_email" type="text" id="u_email" class="tx"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> 联系方式</td>
<td><input name="u_tel" type="text" id="u_tel" class="tx"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交" onClick="javascript:document.all('step').value='reg'" class="button">
<input type="reset" name="Submit2" value="取消" class="button"></td>
</tr>
</table></td>
</tr></form>
</table>
zanpo 2003-09-24
  • 打赏
  • 举报
回复
写在VBscript的过程里
sub btn_onclick

if () then

else

alert('密码输入前后不一致!')

exit sub

end sub

28,406

社区成员

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

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