发新话题
打印

如何提交判断text是空就弹出一个窗口警告?

如何提交判断text是空就弹出一个窗口警告?

怎样提交判断text是空就弹出一个窗口警告的代码怎样写啊~?

TOP

<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>

TOP

呵呵,上面的对,不过VBSCRIPT也可以  
<script  language=vbscript>  
function  checkform()  
   if  (form1.txt1.value=="")  then  
       msg("不能为空")  
   end  if  
</script>

TOP

<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>

TOP

发新话题