Home  >  Article  >  Web Front-end  >  js method to detect that the input content is all spaces_javascript skills

js method to detect that the input content is all spaces_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:50:061208browse

JavaScript method to determine that the input content cannot be all spaces, to avoid that the content of the input box is all spaces:

Copy code The code is as follows:



<script><br> function checkBlankSpace(str){<br> while(str.lastIndexOf(" " )>=0){<br> str = str.replace(" ","");<br> }<br> if(str.length == 0){<br> alert("The input cannot be all Empty");<br> }<br> }<br> function test(){<br> var testStr = document.getElementById("test").value;<br> checkBlankSpace(testStr);<br> }<br> </script>






Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn