function testnull() {
if(document.all.aaa.value=="")
{alert("您输入的空值,请重新输入,谢谢!")
 return false;
}
}

解决方案 »

  1.   

    <html>
    <head>
    <script>
    function testnull() {
    if(document.all.aaa.value==""){alert("您输入的空值,请重新输入,谢谢!");return ;}
    }
    </script>
    </head>
    <body>
    <form action="lll.htm">
    <input name=aaa value="">
    <input type=submit name=ok value="OK" onclick="testnull();return false;">
    </form></body>
    </html>
      

  2.   

    <html>
    <head>
    <script>
    function testnull() {
    if(document.all.aaa.value==""){
    alert("您输入的空值,请重新输入,谢谢!");
    return false;
    }
    }</script>
    </head>
    <body>
    <form action="lll.htm" onsubmit="javascript:return testnull();">
    <input name=aaa value="">
    <input type=submit name=ok value="OK">
    </form></body>
    </html>
      

  3.   

    wangxj0600(旁观拍手笑疏狂,疏又何妨,狂又何妨): 不对呀,你的修改,输入与不输入都要提交!能不能让它为空时,不提交呢???
      

  4.   

    用 coffee_cn(coffee)  的应该可以
      

  5.   

    输入全是空格应视为空
    <script>
    String.prototype.Trim = function() {
      return this.replace(/(^\s*)|(\s*$)/g, "");
    }function testnull(form) {
      if(form.aaa.value.Trim()==""){
        alert("您输入的空值,请重新输入,谢谢!");
        return false;
      }
    }
    </script>
    <form action="xxx.htm" onsubmit="return testnull(this);">
    <input name=aaa value="">
    <input type=submit>
    </form>