| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 944 人关注过本帖
标题:判断输入是否全是空格???
只看楼主 加入收藏
lzlcn
Rank: 2
来 自:广东网络公司
等 级:论坛游民
帖 子:100
专家分:10
注 册:2007-5-18
结帖率:100%
收藏
 问题点数:0 回复次数:3 
判断输入是否全是空格???

请问怎么才能判断用户注册时输入的是否为空格,只有是空格就弹出警告提示错误
如何在下面的JS加入验证呢?

function VerifyInput()
{
username = document.myform.username.value;
if (username == "")
{
alert("请填写您的用户名");
document.myform.username.focus();
return false;
}

password1 = document.myform.password1.value;
if (password1 == "")
{
alert("请填写您的密码");
document.myform.password1.focus();
return false;
}

password1 = document.myform.password1.value;
if (password1.length<6)
{
alert("密码长度不能少于6位");
document.myform.password1.focus();
return false;
}


password2 = document.myform.password2.value;
if (password2 == "")
{
alert("请填写您的确认密码");
document.myform.password2.focus();
return false;
}



if (password2 == password1)
{
}
else
{
alert("您两次输入的密码不相同");
document.myform.password2.focus();
return false;
}

truename = document.myform.truename.value;
if (truename == "")
{
alert("请填写您的真实姓名");
document.myform.truename.focus();
return false;
}



infonumber = document.myform.infonumber.value;
if (infonumber == "")
{
alert("请填写您的身份证号");
document.myform.infonumber.focus();
return false;
}

infonumber = document.myform.infonumber.value;
if (infonumber.length<18)
{
alert("您填写的身份证号输入有误");
document.myform.infonumber.focus();
return false;
}

school = document.myform.school.value;
if (school == "")
{
alert("请填写您的毕业学院");
document.myform.school.focus();
return false;
}


email = document.myform.email.value;
if (email == "")
{
alert("请填写您的电子邮件(Email)");
document.myform.email.focus();
return false;
}

if(document.myform.email.value.length!=0)
{
if (document.myform.email.value.charAt(0)=="." || document.myform.email.value.charAt(0)=="@"|| document.myform.email.value.indexOf('@', 0) == -1 || document.myform.email.value.indexOf('.', 0) == -1||document.myform.email.value.lastIndexOf("@") ==document.myform.email.value.length-1 || document.myform.email.value.lastIndexOf(".")==document.myform.email.value.length-1)
{
alert("您输入的电子邮件(Email)格式不对");
document.myform.email.focus();
return false;
}
}
else
{
alert("Email的不能为空!");
document.myform.email.focus();
return false;
}

tel = document.myform.tel.value;
if (tel == "")
{
alert("请填写您的联系电话");
document.myform.tel.focus();
return false;
}

address = document.myform.address.value;
if (address == "")
{
alert("请填写您的通信地址");
document.myform.address.focus();
return false;
}

postcode = document.myform.postcode.value;
if (postcode == "")
{
alert("请填写您的邮政编码");
document.myform.postcode.focus();
return false;
}
}
先谢了

搜索更多相关主题的帖子: 空格 判断 输入 
2007-05-22 11:53
lzlcn
Rank: 2
来 自:广东网络公司
等 级:论坛游民
帖 子:100
专家分:10
注 册:2007-5-18
收藏
得分:0 

请高手帮我更改这个JS验证,补充验证的不足,比如输放的真实姓名要为中文,联系电话输入的格式为0752-11111111或手机134××××119


弃我去者昨日之日不可留,乱我心者今日之日多烦忧。
2007-05-22 11:58
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
2007-05-22 13:16
laoshu1
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2007-4-14
收藏
得分:0 
帮忙顶一下先
2007-05-22 17:40
快速回复:判断输入是否全是空格???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017235 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved