<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户注册-阶段一</title>
<script language="javascript">
function checkForm(){
if(checkUserName()&&checkPass1()&&checkPass2()&&checkYear()&&checkEmail()&&checksex()){
return true;
}else{
return false;
}
}
function checkUserName(){
var name=document.myform.txtUser.value;
var text10=document.getElementById("div1");
text10.innerHTML="";
if(name==""){
text10.innerHTML="请输入用户名!";
return false;
document.myform.txtUser.focus();
}
if(name.length<4||name.length>16){
alert("用户名输入的长度为4-16个字符!");
return false;
document.myform.txtUser.focus();
}
for(var i=0;i<name.length;i++){
var charTest=name.toLowerCase().charAt(i);
if((!(charTest>='0'&&charTest<='9'))&&(!(charTest>='a'&&charTest<='z'))&&(charTest!='_'))
{
alert("用户名包含非法字符,只能包含字母,数字和下划线!");
return false;
document.myform.txtUser.focus();
}
}
return true;
}
function checkPass1(){
var pass1=document.myform.txtPass1.value;
if(pass1==""){
alert("密码不能为空!");
return false;
document.myform.txtPass1.focus();
}else if(pass1.length<6||pass1.length>12){
alert("密码长度为4-16个字符!");
return false;
document.myform.txtPass1.focus();
}
return true;
}
function checkPass2(){
var pass2=document.myform.txtPass1.value;
var pass3=document.myform.txtPass2.value;
if(pass2!=pass3){
alert("确认密码与输入密码不一致!");
return false;
document.myform.txtPass2.focus();
}
return true;
}
function checkYear(){
var year=document.myform.txtYear.value;
var month=document.myform.txtMonth.value;
var day=document.myform.txtDay.value;
var time=new Date();
var nowYear=time.getYear();
if(year<1949||year>nowYear){
alert("年份范围从1949-2008年");
return false;
document.myform.txtYear.focus();
}
if(month>12||month<1){
alert("月份范围是1-12!");
return false;
document.myform.txtMonth.focus();
}
if(day>31||day<1){
alert("日期范围是1-31!");
return false;
document.myform.txtDay.focus();
}
for(var i=0;i<year.length;i++){
var charTest=year.toLowerCase().charAt(i);
if((!(charTest>='0'&&charTest<='9')))
{
alert("日期只能是数字!");
return false;
document.myform.txtYear.focus();
}
}
return true;
}
function checkEmail(){
var email=document.myform.txtEmail.value;
if(email==""){
alert("电子邮件不能为空!");
return false;
document.myform.txtEmail.focus();
}else if(email.indexOf("@")==-1||email.indexOf(".")==-1){
alert("电子邮件格式不正确\n必须包含@符号和.符号!");
return false;
document.myform.txtEmail.focus();
}else if(email.indexOf("@",0)==0||email.indexOf(".",0)==0){
alert("@符号和.符号不能在邮件地址的第一位!");
return false;
document.myform.txtEmail.focus();
}
else if(email.indexOf("@",0)==email.length-1||email.indexOf(".",0)==email.length-1){
alert("@符号和.符号不能在邮件地址的最后一位!");
return false;
document.myform.txtEmail.focus();
}
return true;
}
/*性别测试*/
function checksex(){
if(document.myform.sex[0].checked==false&&document.myform.sex[1].checked==false){
alert("请选择性别!");
return false;
}
return true;
}
</script>
</head>
<body>
<form method="post" action="" name="myform" onSubmit="return checkForm()">
<p style="size:20px"><img src="iamge/pp.JPG"></p>
<hr>
<p>用户名:<input type="text" name="txtUser" onBlur="checkUserName()"><div id="div1" style="display:inline"></div></p>
<p>密 码: <input type="password" name="txtPass1"><div id="div2" style="display:inline"></div> </p>
<p>确认密码:<input type="password" name="txtPass2"></p>
<p>性 别: 男<input type="radio" name="sex"> 女<input type="radio" name="sex"></p>
<p>电子邮件地址:<input type="text" name="txtEmail"></p>
<p>出生日期:<input type="text" name="txtYear" size="8">年<input type="text" name="txtMonth" size="5">月<input type="text" name="txtDay" size="5">日</p>
<p></p>
<hr>
<p align="center"><input type="submit" value="提交"> <input type="reset" value="重填"></p>
</form>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
北大青鸟ACCP5.0JavaScript特效与表单验证-上机作业源代码
共109个文件
jpg:55个
html:27个
gif:12个
需积分: 10 69 下载量 58 浏览量
2008-06-22
19:02:08
上传
评论
收藏 4.26MB RAR 举报
温馨提示
北大青鸟ACCP5.0JavaScript特效与表单验证-书中示例源代码<br>。都是自己手写的代码,我正在学习的内容。这部分是上机作业。大家交流一下吧。
资源推荐
资源详情
资源评论
收起资源包目录
北大青鸟ACCP5.0JavaScript特效与表单验证-上机作业源代码 (109个子文件)
pp.bmp 452KB
pp.bmp 452KB
Thumbs.db 68KB
Thumbs.db 60KB
Thumbs.db 43KB
Thumbs.db 41KB
Thumbs.db 33KB
Thumbs.db 31KB
Thumbs.db 17KB
Thumbs.db 15KB
Thumbs.db 12KB
Thumbs.db 10KB
Thumbs.db 5KB
fish.gif 27KB
bg.gif 5KB
fish.gif 5KB
login_submit.gif 2KB
submit.gif 2KB
backbutton.gif 1KB
warning.gif 1KB
login_head.gif 804B
bg1.gif 221B
bg.gif 137B
bg2.gif 57B
MenuBg.gif 53B
index.html 4KB
index.html 4KB
index.html 3KB
index.html 3KB
index.html 2KB
index.html 2KB
selectAll.html 2KB
index.html 2KB
index.html 2KB
index.html 2KB
index.html 1KB
index.html 1KB
main.html 1KB
index.html 1KB
index.html 1KB
index.html 1KB
autumn.html 1KB
spring.html 1KB
automn.html 1KB
summer.html 1KB
winter.html 1010B
index.html 976B
index.html 828B
index.html 679B
index.html 651B
index.html 545B
virus.html 360B
pic4.jpg 647KB
pic0.jpg 562KB
sea.jpg 180KB
pic2.jpg 169KB
autumn.jpg 167KB
pic1.jpg 156KB
top.jpg 155KB
foot.jpg 152KB
content2.jpg 148KB
right.jpg 146KB
content1.jpg 144KB
pic3.jpg 134KB
pic1.jpg 117KB
top.jpg 98KB
bottom.jpg 90KB
spring.jpg 84KB
pic3.JPG 82KB
pic2.jpg 79KB
winter.jpg 79KB
pic4.JPG 71KB
summer.jpg 66KB
top2.jpg 65KB
pic.jpg 62KB
left.jpg 57KB
right.jpg 55KB
lady_0007.jpg 52KB
top.jpg 47KB
top.jpg 40KB
top.jpg 38KB
pp.JPG 26KB
m2.jpg 24KB
help_5.jpg 23KB
right.jpg 21KB
background.jpg 19KB
3.JPG 17KB
4.JPG 16KB
1.JPG 16KB
foot.jpg 16KB
m1.jpg 15KB
2.JPG 15KB
5.JPG 15KB
foot.jpg 14KB
4.jpg 13KB
2.jpg 11KB
1.jpg 10KB
back2.jpg 10KB
3.jpg 9KB
menu.jpg 8KB
共 109 条
- 1
- 2
资源评论
JacobTrump
- 粉丝: 11
- 资源: 82
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功