日期:2014-05-16  浏览次数:20383 次

求助:关于页面注册验证输入内容的问题!!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<script type="text/javascript">
function info()
{
var name=document.getElementById("name").value;
var password=document.getElementById("password").value;
var phone=document.getElementById("phone").value;
var sex=document.getElementById("sex").value;
var like=document.getElementById("like").value;
var jobs=document.getElementById("jobs").value;
if(name.length==0)
{
document.getElementById("namenull").innerHTML="姓名不能为空";
return false;


}
else if(password.length==0)
{
   document.getElementById("passwordnull").innerHTML="密码不能为空";
   return false;

}
else if(phone.length==0)
{
   document.getElementById("phonenull").innerHTML="电话不能为空";
   return false;

}
else if(sex.length==0)
{
   document.getElementById("sexnull").innerHTML="性别不能为空";
   return false;

}
else if(like.length==0)
{
   document.getElementById("likenull").innerHTML="爱好不能为空";
   return false;

}
else
{
document.getElementById("jobsnull").innerHTML="工作不能为空";
}




}
</script>
<form name="myform1" id="myform1" >
<fieldset>
<legend>调查表</legend>
<div align="center">调查表</div>
姓名&nbsp;<input type="text" id="name" /><label id="namenull" ></label><br /><br />
密码&nbsp;<input type="password" id="password" /><label id="passwordnull" class="lb"></label><br /><br />
性别&nbsp;<input type="radio" id="sex" value="男"/>男 <input type="radio" id="sex" value="女"/>女<label id="sexnull" class="lb"></label><br /><br />
爱好&nbsp; <input type="checkbox" id="like" value="电影" />电影&nbsp;
<input type="checkbox" id="like" value="运动" />运动&nbsp;
<input type="checkbox" id="like" value="音乐" />音乐&nbsp;
<input type="checkbox" id="like" value="其他" />其他&nbsp; <label id="likenull" class="lb"></label><br /><br />
职业&nbsp; <select id="jobs"><option></option><option>教师</option><option>学生</option></select><label id="jobnull" class="lb"></label><br /><br />
手机&nbsp;<input type="text" id="phone" /><label id="phonenull" class="lb"></label><br /><br />
建议&nbsp;<textarea rows="10" cols="100"> </textarea><br /><br />

            <input type="button" value="提交" onclick="info()">
</f