用正则表达式最简单,但是我不会:(
不过有复杂的办法
function check()
{
a=0;
for(i=0;i<document.form1.problem.value.length;i++)
{    if(document.form1.problem.value.charAt(i)!=" "||document.form1.problem.value.charAt(i)!=" ")
         return true;
     a=a+1 
}
if (a==document.form1.problem.value.length)
{
alert("不能全部为空格");
return false;
}
}

解决方案 »

  1.   

    function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
    <form id="form1" method=post action="right.asp" name="form1" onsubmit="javascript: return(document.form1.problem.value.Trim()!='');">
      

  2.   

    兄弟的方法可以了,但是我的问题提示(“问题不能为空”)却没有了,怎么加?多关照呀,我不是专门学JAVASCRIPT的,水平不高哦,谢谢
      

  3.   

    加一个trim函数就行了
    function check()
    {   if(trim(document.form1.problem.value)=="")
    {  alert("产品问题不能不填写!");
       return false;
    }
    if(trim(document.form1.problem.value)!="")
    {  
       return true;
    }
     alert("产品问题不能不填写!");
    return false;
    }
      

  4.   

    兄弟的方法可以了,但是我的问题提示(“问题不能为空”)却没有了,怎么加?多关照呀,我不是专门学JAVASCRIPT的,水平不高哦,谢谢??????????function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
    function check()
    {
        if(document.form1.problem.value.Trim()=="")
        {
            alert("问题不能为空!");
            document.form1.problem.value = ""; //去除输入的空格
            document.form1.problem.focus();    //将焦点定义在输入框内
            return false;
         }
        return true;
    }
    <form id="form1" method=post action="right.asp" name="form1" onsubmit="javascript: return check();">