function aa(strName)
{
   if(strName=="")
   {
      alert("名字不能为空!");
      return false;  //试一试
    }
}

解决方案 »

  1.   

    <script>
    function CheckForm()
    {
    for(iIndex=0;iIndex<document.forms[0].elements.length;iIndex++)
    {
    if(document.forms[0].item(iIndex).tagName=="INPUT")
    {
    if(document.forms[0].item(iIndex).type=="text")
    {
    if(document.forms[0].item(iIndex).value=="")
    {
    return false;
    }
    }
    }
    }
    return true;
    }
    </script>
    <form>
    <input type=text id="T1" value="">
    <input type=text id="T2" value="">
    <input type=text id="T3" value="">
    <br>
    <input type=button id="B1" value="效验" onclick="if(!CheckForm()){window.confirm('存在NULL')}">
    </form>
      

  2.   

    <input type=button value=submit onclick="return bb()" id=btSubmit name=btSubmit runat=server>
    function aa(strName)
    {
       if(strName=="")
       {
          alert("名字不能为空!");
          return false;  //试一试
        }
       form1.submit();
    }
      

  3.   

    <script>
    function aa(strName)
    {
       if(strName=="")
       {
          alert("名字不能为空!");
          return false; 
        }
       else
          return true;
    }
    </script>
    <form name=xxx action=xxxx onsubmit="return aa()">
                                         ~~~~~~~
      

  4.   

    还是会的,不过我已有办法解决了,仍然谢谢各位!顺便问一下,Html控件没有visible属性,如何实现类似的功能呢?
      

  5.   

    <input type="button" value="button" style="visibility:hidden">
    <input type="button" value="button" style="visibility:visible">visibility是有占位.