剑心 2006-3-10 15:22
如何提交判断text是空就弹出一个窗口警告?
怎样提交判断text是空就弹出一个窗口警告的代码怎样写啊~?
liuzhusuoai 2006-3-10 15: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>
xingyungulang 2006-3-10 15:24
呵呵,上面的对,不过VBSCRIPT也可以
<script language=vbscript>
function checkform()
if (form1.txt1.value=="") then
msg("不能为空")
end if
</script>
yangchilang 2006-3-10 15:24
<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>