验证不能为空,null,多个空格的js

时间:2014-06-04 05:11:31
【文件属性】:
文件名称:验证不能为空,null,多个空格的js
文件大小:2KB
文件格式:JS
更新时间:2014-06-04 05:11:31
验证不能为空,null,多个空格的js function validatename(){ var text=document.getElementById('username').value; //if(text==null||text==''){ //不为空和输入的不是空格 if(text==null||text.replace(/^\s+,""/).replace(/^\s+$/,"")==''){ alert('用户名不能为空!'); //重新获得焦点 document.getElementById('username').focus(); return false; } return true; }

网友评论