这得看你想要哪些判断条件,如果就单纯判断不为空:
<script language ="javascript">
function OK()
{  
   var aa = document.getElementById("text1").value;
   if(aa.length=="")
   {
       alert("必须填写");
       return false;
    }
    else
    {
      return ture;
    }
}</script>
<input type="text" id="text1">
<input type="button" id="button1" value="提交" onclick="OK()">

解决方案 »

  1.   

    script language ="javascript">
    function OK()
    {  
       var aa = document.getElementById("text1").value;
       if(aa.length<1)
       {
           alert("必须填写");
           return false;
        }
        else
        {
          return ture;
        }
    }</script>
    <input type="text" id="text1">
    <input type="button" id="button1" value="提交" onclick="OK()">
      

  2.   

    if (this.txt_userPwd.Text.Trim() == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('密码不能为空!')</script>");
                this.txt_userPwd.Focus();//获取焦点
              
                return;
            }
    else
    {
    }
      

  3.   

    <input type="button" id="button1" value="提交" onclick="return OK()">
      

  4.   

    function checkform()
    {}return checkform();
      

  5.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    </head><body>
    <form action="123.htm" method="get">
    <input>
    <input type="submit" value="submit" onclick="return checkNull();">
    <input name="T1" size="20"><input name="T2" size="20"><input name="T3" size="20"><input name="T4" size="20"></form>
    <script>
    function  checkNull()
    {
    var inputs = document.getElementsByTagName("INPUT");
    for(var i = 0 ; i < inputs.length;i++)
    {
    if(inputs[i].type==null || (inputs[i].type!=null&&inputs[i].type.toLowerCase()=="text"))
    {
    if(inputs[i].value.replace(/ /g,"")=="")
    {
    alert("请填写所有的内容");
    return false;
    }
    }
    }
    }
    </script>
    </body></html>