//验证码的全局变量
var numv2;
//倒计时全局变量
var time01 = 60;
var time = 1200;
var minute = time / 60;
var time04;
//时间函数
function f1() {
var eveday = new Date();
var year = eveday.getFullYear();
var month = eveday.getMonth();
f3(month);
var day = eveday.getDay();
f3(day);
var hours = eveday.getHours();
f3(hours);
var minutes = eveday.getMinutes();
f3(minutes);
var seconds = eveday.getSeconds();
f3(seconds);
var today = eveday.getDay();
var week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
f2(year);
document.getElementById('p1').innerText = year + '.' + f3(month) + '.' + f3(day) + ' ' + f3(hours) + ':' + f3(minutes) + ':'
document.getElementById('p2').innerText = f3(seconds)
document.getElementById('p3').innerHTML = ' ' + '今年是' + f2();
document.getElementById('p4').innerHTML = week[today];
}
//网页打开首先刷新
window.onload = function () {
f1(); //时间函数
f4(); //点击输入框变换标题文字
}
//求闰年平年的函数
function f2(num) {
= num;
if ( % 4 == 0 && % 100 != 0 || % 400 == 0) {
return '闰年'
} else {
return '平年'
}
}
//针对时间个位数添加十位为0的函数
function f3(num) {
if (num < 10) {
return '0' + num
} else {
return num
}
}
//每秒钟刷新一次
setInterval(f1, 1000);
//针对标题点击输入框变换文字
function f4() {
var input01 = document.getElementById('input01');
var input02 = document.getElementById('input02');
var input03 = document.getElementById('input03');
var input04 = document.getElementById('input04');
//点击鼠标修改标题文字清空输入框
in = function () {
time04 = setInterval(f6,1000);
in = '';
document.getElementById('div05'). = '20px';
document.getElementById('div05'). = 'yellow';
document.getElementById('div05').innerHTML = '年少时的梦想决定着将来,所以现在趁年轻,还是多睡一会吧';
}
//点击鼠标修改标题文字清空输入框
in = function () {
in = '';
document.getElementById('div05'). = '14px';
document.getElementById('div05'). = 'white';
document.getElementById('div05').innerHTML = '如果生命还剩一天,那么我一定会回到课堂好好听一次课,因为在课堂上,我会觉得度日如年'
}
//点击鼠标修改标题文字清空输入框
in = function () {
in = '';
document.getElementById('div05'). = '15px';
document.getElementById('div05'). = 'pink';
document.getElementById('div05').innerHTML = '别人赖床是因为有钱,想睡多晚就睡多晚。我赖床是因为没钱,能省一餐是一餐';
}
//点击鼠标修改标题文字清空输入框
in = function () {
in = '';
document.getElementById('div05'). = '30px';
document.getElementById('div05'). = 'purple';
document.getElementById('div05').innerHTML = '问世间情为何物,一物降一物'
}
}
//用鼠标点击获取验证码
function f5() {
numv1 = []
AA = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
1, 2, 3, 4, 5, 6, 7, 8, 9, 0
]
for (var i = 0; i < 4; i++) {
BB = Ma() * 29);
numv1.push(AA[BB])
}
numv2 = numv1
document.getElementById('div04').innerText = numv1.join(' ')
}
//倒计时函数
function f6() {
time01 = time01 - 1;
var time02 = f7(time01)
var time03 = f7(minute)
con(time01)
if (time01 == 0) {
minute = minute - 1;
time01 = 60;
}
con(minute)
document.getElementById('div02').innerText = "计时:" + time03 + ':' + time02
if (minute == 0) {
alert('时间到')
clearInterval(time04);
return
}
}
function f7(num) {
if (num < 10) {
return '0' + num
}
return num
}
//点击注册函数
function add() {
//获取内容
var input01 = document.getElementById('input01').value;
var input02 = document.getElementById('input02').value;
var input03 = document.getElementById('input03').value;
var input04 = document.getElementById('input04').value;
//获取的内容传递到函数里处理并获得返回值
var username01 = username(input01);
var passwd01 = passwd(input02);
var Verification_Code01 = Verification_Code(input03);
var phone01 = phone(input04);
var SS;
//对获取的返回值进行处理
//用户名的处理
if (username01 == true) {
SS = 1;
} else {
SS = 0;
alert('用户名必须为中文字符2至4个')
document.getElementById('input01').value = '';
return
}
//密码的处理
if (passwd01 == true) {
SS = 1;
} else {
SS = 0;
alert('密码错误,前四需要是数字字符下划线,密码8位以上');
document.getElementById('input02').value = '';
return
}
//验证码的处理
if (Verification_Code01 == true) {
SS = 1;
} else {
SS = 0;
alert('验证码不正确')
document.getElementById('input03').value = '';
//验证码输入错误后,刷新验证码
f5();
return
}
//验证码的处理
if (phone01 == true) {
SS = 1;
} else {
SS = 0;
alert('手机号码不正确')
document.getElementById('input04').value = '';
return
}
if (SS == 1) {
alert('注册成功')
}
}
//手机号码的函数
function phone(num) {
if == 11) {
var res = /^\d[3456789]\d{10}$/;
res.test(num)
return true
} else {
return false
}
}
//验证码的函数
function Verification_Code(num) {
if () == numv2.join('').toLocaleLowerCase()) {
return true
} else {
return false
}
}
//用户名的函数
function username(num) {
var res = /^[\u4e00-\u9fa5]{2,4}/
if (num)) {
return true
}
return false
}
//密码函数
function passwd(num) {
var res = /^\w{4}[@!?,.&*]/ig
if > 8) {
if (num)) {
return true
}
return false
} else {
alert('密码长度不够')
}
}
//取消直接刷新
function del() {
loca();
}