js判断密码不可以输入空格 js判断密码不可以输入空格 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function IsNull(){ var password=$.trim($("#txtpassword").val()); if(password==""){ alert('密码不能为空'); return false; }return true;} var regNull=/(^\s*)|(\s*$)/g;if(regNull.test("密码")){ 有空格} var regNull=/(^\s*)|(\s*$)/g;if(regNull.test(你的密码值)){ 有空格}顶 <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测过,可用,就是用正则判断一下 var parten = /\s+/ ; 既然楼主不喜欢正则,好吧。。var text = "asdfasd asdfasd";if(text.indexOf(" ") >= 0){ alert("有空格");} 为什么我的vs2008 js编辑页面代码全黑色 文字从左到右滚动!! 通过js的replace()方法替换[] 在线编辑器的问题 讨教,如何在脚本函数中调用脚本函数? 对象不支持此种方法或属性 有关拼音码获得的问题,求各位侠客帮忙 求正则,防止多位数字重复的 怎样取得一个“字符串”所在的宽度?详情请进。。。。。。。 关于easyui datagrid 行编辑 提交前验证 如何根据页面的位置参数,得到改位置上的元素对象? JS 判断上传文件大小
var password=$.trim($("#txtpassword").val());
if(password==""){
alert('密码不能为空');
return false;
}
return true;
}
if(regNull.test("密码")){
有空格
}
if(regNull.test(你的密码值)){
有空格
}
顶
<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测过,可用,就是用正则判断一下
var parten = /\s+/ ;
if(text.indexOf(" ") >= 0)
{
alert("有空格");
}