<input type=text name=txt1>
<input type=submit onclick="javascript:if(document.all.txt1.value==''){alert('内容不能为空!');return false;}">

解决方案 »

  1.   

    修改一下,这样会好一点。
    <input type=text name=txt1>
    <input type=submit onclick="javascript:if(document.all.txt1.value.indexOf('')!=-1){alert('内容不能为空!');return false;}">indexOf是查找字符串中有无" "字符,如没有则函数返回-1,不等于-1也就是输入字符中存在一个或多个""了。
    enjoy!
      

  2.   

    <form action="modify_detail_ok.asp?mod=ad&id=<%=rs("id")%>" method="post" name="ad" onSubmit="return input_onsubmit()">
    function input_onsubmit() 
    {
      if(document.ad.starthour.value=="" && document.input.startmin.value!=="" )
         )
        {
          alert("请填写开始时间!")
          document.ad.starthour.focus()
          return false
        }
    }
    我时这样做的可运行的时候我发现没作用,不知道哪位大侠能帮帮忙!
      

  3.   

    document.input.startmin.value!==""改为document.input.startmin.value !=""还有action="modify_detail_ok.asp?mod=ad&id=<%=rs("id")%>" 
    改为action="modify_detail_ok.asp?mod=ad&id=<%=rs('id')%>" 试试看
      

  4.   

    看着个吧<form action="modify_detail_ok.asp?mod=ad&id=<%=rs('id')%>" method="post" name="ad" onsubmit="return input_onsubmit()">
    <INPUT type="submit" value="sub">
    <INPUT name="starthour">
    <INPUT name="startmin">
    </FORM>
    <SCRIPT language="javascript">
    function input_onsubmit() 
    {
    if(document.ad.starthour.value=="" && document.ad.startmin.value !="" )
    {
    alert("请填写开始时间!")
    return false
    }
    }
    </SCRIPT>
      

  5.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <script language=JavaScript src="calendar.js">
    function input_onsubmit() 
    {
      if(document.ad.starthour.value=""  )
        {
          alert("请填写开始时间!")
          document.ad.starthour.focus()
          return false
        }  if(document.ad.starthour.value!=="" && document.input.startmin.value=="")
        {
          alert("请输入开始时间!")
          document.ad.startmin.focus()
          return false
        } 
    if(document.ad.endhour.value==""&& document.input.endmin.value!=="")
        {
          alert("请输入中止时间!")
          document.ad.endhour.focus()
          return false
        }
    if(document.ad.endmin.value==""&& document.input.endhour.value!=="")
        {
          alert("请输入中止时间!")
          document.ad.endmin.focus()
          return false
        }
    if(document.ad.starthour.value >24 || document.ad.startmin.value>60)
        {
          alert("请输入正确的时间!")
          document.ad.starthour.focus()
          return false
        }
    if(document.ad.endhour.value >24 || document.ad.endmin.value>60)
        {
          alert("请输入起飞地点!")
          document.ad.endhour.focus()
          return false
        }
    }
    </script>
    <!--#include file="OpenDB.inc"-->
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <%
      adid=request("id")
      mad=request("mod")
      conn=application("conn")
      if mad="ad" then
      sql="select * from detail_ad where id="&adid
      rs.open sql,conn,1,1
      na=rs("name")
       if na<>session("UserID")  then 
      response.Redirect "detail_ad.asp"
      else
    %>
    <body>
    <table width="80%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>  <form action="modify_detail_ok.asp?mod=ad&id=<%=rs("id")%>" method="post" name="ad" onSubmit="return input_onsubmit()">
            <table width="112%"  border="1" cellpadding="0" cellspacing="0">
              <tr>
                <td width="27%" align="center" bgcolor="#EEEEEE" >实&nbsp;际&nbsp;播&nbsp;出&nbsp;时&nbsp;间</td>
                <td colspan="4" bgcolor="#EEEEEE"><input name="starthour" type="text" id="starthour" value="<%=rs("starthour")%>" size="4" maxlength="2">
                  时
                    <input name="startmin" type="text" id="startmin" value="<%=rs("startmin")%>" size="4" maxlength="2">
                  分-
                  <input name="endhour" type="text" id="endhour" value="<%=rs("endhour")%>" size="4" maxlength="2">
                  时
                  <input name="endmin" type="text" id="endmin" value="<%=rs("endmin")%>" size="4" maxlength="2">
                  分</td>
              </tr>
              <tr>
                <td align="center" bgcolor="#EEEEEE">历时</td>
                <td colspan="4"><input name="totaltime" type="text" id="totaltime" value="<%=rs("totaltime")%>"></td>
              </tr>
              <tr>
                <td align="center" bgcolor="#EEEEEE">节目制作人</td>
                <td colspan="4"><input name="productor" type="text" id="productor" value="<%=rs("productor")%>"></td>
              </tr>
              <tr>
                <td align="center" bgcolor="#EEEEEE">播&nbsp;出&nbsp;内&nbsp;容</td>
                <td colspan="4">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="5" align="center" bgcolor="#EEEEEE"><textarea name="content" cols="50" rows="4" id="content"><%=rs("content")%></textarea></td>
              </tr>
              <tr>
                <td colspan="5" align="center" bgcolor="#EEEEEE">&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td width="14%">&nbsp;</td>
                <td width="17%"><input type="submit" name="Submit" value="保存"></td>
                <td width="11%"><input type="reset" name="Submit2" value="重新填写"></td>
                <td width="31%" align="center">&nbsp;</td>
              </tr>
            </table>
        </form></td>
      </tr>
      <%
      rs.close
      set rs=nothing
      end if
      end if
       </table>
    </body>
    </html>
    这个是我的源代码
      

  6.   

    将document.input.startmin.value==""改为
    document.ad.startmin.value==""将document.input.endmin.value!==""改为
    document.ad.endmin.value!=""将document.input.endhour.value!==""改为
    document.ad.endhour.value!=""
      

  7.   

    你那里根本就没有name为input的Form啊。