请各位帮帮忙,如题的代码怎么写?谢谢。。

解决方案 »

  1.   

    var str=document.getElmentById("textbox1").value;
    if(/\S/.match(str))
    {
      //不全是空格
    }
      

  2.   

    var str = document.getElementById('txtid').value;
    if(/[^\s]+/.test(str)) alert('不全是空格,有其它字符')
      

  3.   

    <html>
    <head>
    <title>字符串为空或空格是不是一回事呢?</title> 
    </head>
    <script>
    function intp()
    {
    var text = document.getElementById('intp').value;
    if(text=='')
    {
    alert("文本框中为空");
    }
    else if(text.match(' '))
    {
    alert("文本框的字符有空格")
    }
    else
    {
    alert(text);
    }
    }
    </script>
    <body>   
    <input id="intp" type="text" ></input>
    <input type="button" onclick="intp()" value="单击"></input>
    </body>
    </html>