怎样提交判断text是空就弹出一个窗口警告的代码怎样写啊~?
---------------------------------------------------------------
1<script>
2function checkform(){
3if (form1.txt1.value==""){
4alert("不能为空");
5return false;
6}
7}
8</script>
1<form id="form1" onsubmit="return checkform();">
2<input name="txt1" type="text"/>
3<input name="ok" type="submit" value="submit"/>
4</form>
---------------------------------------------------------------
呵呵,上面的对,不过VBSCRIPT也可以
1<script language="vbscript">
2function checkform()
3if (form1.txt1.value=="") then
4msg("不能为空")
5end if
6</script>
---------------------------------------------------------------
1<script>
2function checkform()
3dim errflag, msg
4errflag = True
5
6If len(trim(theForm.text1.value))= 0 then
7msg = "不能为空"
8MsgBox msg, 64, "警告!"
9focusto(0)
10errflag = false
11Exit Function
12End if
13
14checkform = errflag
15theForm.Submit
16End Function
17
18sub focusto(x)
19document.theForm.elements(x).focus()
20end sub
21</script>
1<form name="theform">
2<input name="txt1" type="text"/>
3<input name="ok" type="button" value="submit"/>
4</form>