欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js檢測輸入內(nèi)容全為空格的方法

 更新時(shí)間:2014年05月03日 09:53:24   作者:  
這篇文章主要介紹了js檢測輸入內(nèi)容全為空格的方法,,需要的朋友可以參考下
JavaScript判斷輸入內(nèi)容不能全為空格的方法,用來避免輸入框的內(nèi)容輸入的全是空格:
復(fù)制代碼 代碼如下:

<html>
 <head>
  <script>
   function checkBlankSpace(str){
    while(str.lastIndexOf(" ")>=0){
      str = str.replace(" ","");
    }
    if(str.length == 0){
     alert("輸入不能全為空");
    }
   }
   function test(){
    var testStr = document.getElementById("test").value;
    checkBlankSpace(testStr);
   }
  </script>
 </head>
 <body>
  <input type="text" id="test"/>
  <input type="button" value="測試" onclick="test()">
 </body>
</html>

相關(guān)文章

最新評論