if(document.ping.subject.value.replace(/\s/g,"")==""){
   alert("您输入的内容为空。");
}你的那种办法己经过时了,我都是用这办法的。呵呵

解决方案 »

  1.   

    在脚本中定义一个String原型对象的trim()函数(类似于VBScript的trim()函数):
    String.prototype.trim = function()
    {
        return this.replace(/(^[\s]*)|([\s]*$)/g, "");
    }
    然后判断
    if(document.ping.subject.value.trim()=="")
    if(document.ping.content.value.trim()=="")
      

  2.   

    换成vbscript
    <script  language="vbscript">
    function checkForm()
        if trim(document.ping.subject.value)="" then
            msgbox("请输入标题!")
            checkForm=false
        end if
        if trim(document.ping.content.value)="" then
            msgbox("请输入内容!")
            checkForm=false
        end if
        return true
    end function
    </script>