注册随机表单
var user = document.getElementById('username');
var pwd = document.getElementById('password');
var yz = document.getElementById('yz');
var sjm = document.querySelector('textarea');
var box=document.querySelector('.box');
sui.onclick = function() {
//获取四位数值
var s = Math.floor(Math.random() * (9999 - 1000 + 1) + 1000);
console.log(s);
sjm.innerHTML = s;
if(sui.innerHTML == '获取随机码') {
//定义一个时间
var i = 59;
//执行
function time() {
sui.innerHTML = i + '秒后获取';
i--;
if(i < 0) {
clearInterval(time);
sui.innerHTML = '获取验证码';
}
}
//倒计时定时器
var times = setInterval(time, 1000)
}
btn.onclick = function() {
if(yz.value == s) {
alert('成功');
box.style.display='block';
} else {
alert('失败');
}
}
}
btn1.onclick = function() {
if(btn1.innerHTML == '刷新') {
user.value=null;
pwd.value=null;
yz.innerHTML=null;
sjm.innerHTML=null;
}
}
网友评论