87,992
社区成员
发帖
与我相关
我的任务
分享
var text = "asdfasd asdfasd";
if(text.indexOf(" ") >= 0)
{
alert("有空格");
}
<script type="text/javascript">
function chk(){
var pwd=document.getElementById("pwd").value;
alert(pwd);
var parten = /^\s*$/ ;
if(parten.test(pwd)) {
alert("error");
}
}
</script>
</head>
<body>
<input type="password" id="pwd" name="pwd"/>
<input type="button" onclick="chk()" value="ok" />
经firefox和IE测过,可用,就是用正则判断一下