请问怎样提交判断text是空就弹出一个窗口警告啊

zrqlyc 2003-08-23 07:20:55
怎样提交判断text是空就弹出一个窗口警告的代码怎样写啊~?
...全文
72 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zrqlyc 2003-08-23
  • 打赏
  • 举报
回复
好啦,谢谢啊~
dgm8 2003-08-23
  • 打赏
  • 举报
回复
上面忘了触发事件

<script>
function checkform()
dim errflag, msg
errflag = True

If len(trim(theForm.text1.value))= 0 then
msg = "不能为空"
MsgBox msg, 64, "警告!"
focusto(0)
errflag = false
Exit Function
End if

checkform = errflag
theForm.Submit
End Function

sub focusto(x)
document.theForm.elements(x).focus()
end sub
</script>



<form name=theform>
<input type=text name=txt1>
<input type=button name=ok value=submit onclick=checkform>
</form>
dgm8 2003-08-23
  • 打赏
  • 举报
回复
<script>
function checkform()
dim errflag, msg
errflag = True

If len(trim(theForm.text1.value))= 0 then
msg = "不能为空"
MsgBox msg, 64, "警告!"
focusto(0)
errflag = false
Exit Function
End if

checkform = errflag
theForm.Submit
End Function

sub focusto(x)
document.theForm.elements(x).focus()
end sub
</script>



<form name=theform>
<input type=text name=txt1>
<input type=button name=ok value=submit>
</form>
yanfeng 2003-08-23
  • 打赏
  • 举报
回复
呵呵,上面的对,不过VBSCRIPT也可以
<script language=vbscript>
function checkform()
if (form1.txt1.value=="") then
msg("不能为空")
end if
</script>
Jaron 2003-08-23
  • 打赏
  • 举报
回复
<script>
function checkform(){
if (form1.txt1.value==""){
alert("不能为空");
return false;
}
}
</script>

<form id=form1 onsubmit="return checkform();">
<input type=text name=txt1>
<input type=submit name=ok value=submit>
</form>
zrqlyc 2003-08-23
  • 打赏
  • 举报
回复
能写一个出来看看吗?
Memocs 2003-08-23
  • 打赏
  • 举报
回复
用 javascript, alert

28,390

社区成员

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

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