日期:2014-05-17  浏览次数:20654 次

请问怎么用JS判断输入框中输入的全是空格???
知道的帮帮忙

------解决方案--------------------
<html>
<body>
<input type="text" id="1" />
<input type="button" value="validator" id="2" onclick="validator();" />
</body>
</html>
<script>
function validator()
{
var var1 = document.getElementById("1") ;
alert(var1);
var parten = /^\s*$/ ;
if(parten.test(var1))
alert("all spaces!") ;
else
alert("not all spaces");
}
</script>