- 3
- 0
- 约3.89千字
- 约 7页
- 2017-01-30 发布于重庆
- 举报
form对象综合应用
form表单综合练习
编写程序,设计BBS论坛注册页面,页面如下:
要求:
对输入进行输入为空验证,为空验证后,相关的输入框获取焦点。
如未输入用户名:
点击确定按钮后:
对密码及手机号按要求利用正则表达式进行合法性验证,要求:密码为6—10个字符,手机号为11位数字。
密码输入的字符数量不够:
手机号输入有问题
实现对头像选择的预览效果。
选择头像1
选择头像2
实验代码:
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN /TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlns=/1999/xhtml
head
meta http-equiv=Content-Type content=text/html; charset=utf-8 /
title无标题文档/title
script language=javascript
function setimage(){
document.images.myimg.src=document.form1.select.value;
}
function check(){
var name=document.form1.username.value;
var pass1=document.form1.userpass1.value;
var pass2=document.form1.userpass2.value;
var phone=document.form1.userphone.value;
if(name==){
alert(用户名为空,请输入!);
document.form1.username.focus();
return false;
}
if(pass1==){
alert(密码为空,请输入!);
document.form1.userpass1.focus();
return false;
}
if(pass1!=pass2){
alert(两次密码不一致,请重新输入!);
document.form1.userpass2.focus();
return false;
var phone=document.form1.userphone.value;
if(phone.length==0){
alert(手机号码为空);
document.from1.userphone.focus();
}
return true;
}
//判断密码为6-12个字符
var exp1=/^\w{6,10}$/;
var obj1=new RegExp(exp1);
if(obj1.test(pass1)==false){
alert(密码格式有错,请重新输入!);
document.from1.userphone.focus();
return false;
}
var exp2=/^\d{11}$/;
var obj2=new RegExp(exp2);
if(obj2.test(phone)==false){
alert(手机号码格式有错,请重新输入!);
document.from1.userphone.focus();
return false;
}
}
function txtfocus(){
var obj=window.event.srcElement;
obj.style.background=#ffff66;
}
function txtblur(){
var obj=window.event.srcElement;
obj.style.background=#ffffff;
}
/script
/head
body
pFORM表单综合运用 /p
p align=centerstrongBBS论坛注册 /strong/p
form id=form1 name=form1 method=post action= onsubmit=return check()
table width=3
您可能关注的文档
最近下载
- (高清版)DB31∕T 1487-2024 国际医疗服务规范.docx VIP
- 精益管理措施在医院手术室医用耗材管理中的应用.pdf VIP
- 2026及未来5年中国商务男装市场运行态势及战略咨询报告.docx
- 泸州市高2023级(2026届)高三(一诊)数学试题(含标准答案).pdf
- 新城地产商开目标成本主要科目价格测算标准-定稿.pptx VIP
- 12月1日艾滋病宣传日活动方案模板(集锦5篇).docx VIP
- 2024年湖南铁道职业技术学院单招计算机测试模拟题库必考题.docx VIP
- 遗产分割起诉状.docx VIP
- 2021年重庆市中考物理真题(a卷).pdf VIP
- 2025年度民主生活会对照检查材料8篇五个带头合集.docx VIP
原创力文档

文档评论(0)