文本框 condition 处于一个form( Condition )里面
我这样写JS代码:
<script language="Javascript">
if(IsEmpty(document.Condition .condition.value))
{
  alert('请输入条件');
  return false;
}
</script>
我运行页面的时候,当文本框不输入内容,它不弹出提示
问题出在哪里啊  我原来这样用正常的呀

解决方案 »

  1.   

    试一下这个<script language="Javascript">
    if(IsEmpty(document.Condition .condition.value))
    {
      alert('请输入条件');
      return false;
    }
      return true;
    </script>
      

  2.   

    不弹出提示框,说明根本没有进入if 的内部。你先这样该:<script language="Javascript">
      alert('请输入条件');</script>看能不能输出:如果可以,就说明是你的逻辑判断的条件有问题!
    所以没有进入内部!
      

  3.   

    <script language="Javascript">
    if(document.Condition .condition.value=="")
    {
      alert('请输入条件');
      return false;
    }
    </script>
      

  4.   

    <script language="Javascript">
    if(document.Condition .condition.value.length==0)
    {
      alert('请输入条件');
      return false;
    }
    </script>
      

  5.   

    <script language="Javascript">
    if(document.Condition .condition.value==""||document.Condition .condition.value==null)
    {
      alert('请输入条件');
      return false;
    }
    </script>
      

  6.   

    把script 代码放到form 后面 可能form还没加载到 就执行呢 scirpt 结果代码出错导致问题
      

  7.   

    <script Language="JavaScript">
    <!--
     function check_input(theForm)
    {      if ((theForm.name.value == "")|(isspacestring(theForm.name.value)))
          {
            alert("请输入用户名.");
            theForm.name.focus();
            return false;
          }
          
       -->
    </script>
    同时还要在你的form的代码中加进这个函数:
    <form method="POST" action="log.jsp" onSubmit="return check_input(this)" name="theForm">
      

  8.   

    楼上说对,光有函数是不行的,必须加入到form中去
      

  9.   

    只要访问到对象,value==“” 或value.length=0 都可以判断,楼主写的VB的判断语法吗。
      

  10.   

    谢谢大家 已经解决了 
    原因是没有在form 里面写 onsubmit  呵呵
      

  11.   

    //判断小数点
    function isValid_dot(val)
    {    var subvalue;    if (val.indexOf(".",0) != -1){    subvalue = val.substring(val.indexOf(".",0)+1);   if (subvalue.indexOf(".",0) != -1){
        return false;
      } } return true;}//判断负号
    function isValid_negative(val)
    {    var subvalue;    if (val.indexOf("-",0) != -1){    if (val.indexOf("-",0) > 0){
         return false;
       }    subvalue = val.substring(val.indexOf("-",0)+1);   if (subvalue.indexOf("-",0) != -1){
        return false;
      } } return true;
    }//判断合适长度
    function isRight_length(val,num)
    {
         var len = parseInt(num);  if (isNaN(len)){ return true;}  if (val.length != len){
       return false;
     }     return true;}//***************************************************************************************************
    //--- 从ATrimStr中去掉符合条件的字符串ASubStr
    //--- 参数:
    //--- ATrimStr:要去掉符合条件字符串的字符串
    //--- ASubStr:要去掉的子字符串
    //--- AWhere 0:去掉所有的, 1:去掉左边相连的,2:去掉右面的相连的
    //--- 返回: 处理完的字符串
    //--- 创建日期:       2001-07-27 最近更新日期:   2001-07-27
    //--- 创建程序员: xg_delayth 最近更新程序员: xg_delayth
    //--- 维护程序员:     xg_delayth
    //--- 举例: trimSubStr(" usj  29 "," ",0) 返回 "usj29"
      function trimSubStr(ATrimStr,ASubStr,AWhere){
        var tTrLength,tSbLength,tempLength;
        var tempString;
        var i;    tTrLength = ATrimStr.length;
        tSbLength = ASubStr.length;    if (tSbLength == 0){return ATrimStr;}
        if (tSbLength > tTrLength){return ATrimStr;}    tempString = ATrimStr;
        switch(AWhere){
          case 0://所有
            do{
              tempLength = tempString.length;
              tempString = tempString.replace(ASubStr,"");
            } while(tempLength != tempString.length);
            break;
          case 1://左
            while (true){
              if (tempString.length < tSbLength) break;
              for (i = 0;i < tSbLength;i++)
                if (ASubStr.charAt(i) != tempString.charAt(i))
                  return tempString;
              tempString = tempString.replace(ASubStr,"");
            };
          case 2://右
            while(true){
              tempLength = tempString.length;
              if (tempLength < tSbLength){return tempString;}
              for (i = 0;i < tSbLength;i ++){
                if (ASubStr.charAt(i) != tempString.charAt(tempLength - tSbLength+i)){
                  return tempString;
                }
              }
              tempString = tempString.substr(0,tempLength-tSbLength);
            };
          default:
            return tempString;
        }
        return tempString;
      }
    //***************************************************************************************************
    //××××××××××××扩充函数列表×××××××××××××××××××
    //整理域的属性值,校验v_×域的值是否符合标准
    function  packUp(obj) {  if(obj == null) {    alert(obj.v_name+"的值不能为空!");
        return false;
      }  //if (obj.value != null){
      //  obj.value = trimSubStr(trimSubStr(obj.value," ",1)," ",2);
      //}
      //创建v_name属性
      try {    if(obj.v_name == null) {      //alert("创建v_name属性");
          obj.v_name = new String(obj.name);
        }
      }catch(exception){}  //创建v_type属性
      try {    if(obj.v_type == null) {      //alert("创建v_type属性");
          obj.v_type = new String("string");
        }
      }catch(exception){}  //创建v_minlength属性
      try {    if(obj.v_minlength == null) {      //alert("创建v_minlength属性");
          obj.v_minlength = new String("0");
        }
      }catch(exception){}  //创建v_maxlength属性
      try {    if(obj.v_maxlength == null) {      //alert("创建v_maxlength属性");
          obj.v_maxlength = new String("");
        }
      }catch(exception){}  //创建v_maxvalue属性
      try {    if(obj.v_maxvalue == null) {      //alert("创建v_maxvalue属性");
          obj.v_maxvalue = new String("");
        }
      }catch(exception){}  //创建v_minvalue属性
      try {    if(obj.v_minvalue == null) {      //alert("创建v_minvalue属性");
          obj.v_minvalue = new String("");
        }
      }catch(exception){}  //创建v_must属性
      try {    if(obj.v_must == null) {      //alert("创建v_must属性");
          obj.v_must = new String("0");
        }
      }catch(exception){}  return true;
    }