请问怎么才能判断用户注册时输入的是否为空格,只有是空格就弹出警告提示错误
如何在下面的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;
}
}
先谢了