Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 16:50:06
Original
1227 people have browsed it

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>






Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template