泉州结石病医院:判断是否为空

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 17:32:14
<script language="vbscript">
function checkform()
dim msg
if len(trim(theForm.title.value))=0 then
msg=MsgBox("error",48,"err")
msg.show()
theForm.title.focus()
checkform=false
Exit Function
end if
theForm.submit
end function
</script>
<form id="theForm" name="theForm" method="post" action="message_main.asp" >
<input type="submit" name="Submit" value="提交" onclick=checkForm()>
<input type="reset" name="Submit2" value="重置" /></td>
</form>

虽然是有个对话框弹出,但是它还是会提交,我想要的是弹出对话框确定后,不提交!应该怎么弄!
是不是在BUTTON 里的ONCLICK??

<script language="vbscript">
function checkform()
dim msg
if len(trim(theForm.title.value))=0 then
msg=MsgBox("error",48,"err")
msg.show()
theForm.title.focus()
Exit Function
else
theForm.submit
end if
end function
</script>
<form id="theForm" name="theForm" method="post" action="message_main.asp" >
<input type="submit" name="Submit" value="提交" onclick=checkForm()>
</form>
这样,它还是提交了,究竟怎么了!!高手请指教下!谢谢!

因为<input type="submit" name="Submit" value="提交" onclick=checkForm()>
属性是submit,只要点击就会执行提交表单,你换成button就可以了,函数checkForm()里面已经写theForm.submit
还有注意一些小的语法错误。
完毕!