html前端登录验证码,前端登录页面开发_js生成验证码并验证

/p>

前端集成开发工具:

margin: 0;

padding: 0;

}

a {

text-decoration: none;

}

.main_bar {

width: 100%;

height: 350px;

margin-top: 200px;

}

.login_form {

width: 30%;

height: 80%;

margin: 0 auto;

/*border:2px solid #16A085;*/

border-radius: 15px;

padding: 10px;

background: #ECF0F1;

}

.name,

.pwd,

.sbm_btn {

display: block;

width: 70%;

margin: 0 auto;

height: 35px;

font-size: 16px;

border-color: transparent;

border-radius: 5px;

border: 0;

padding-left: 8px;

}

.yzm {

height: 35px;

margin: 0 auto;

width: 72%;

line-height: 35px;

position: relative;

margin-bottom: 10px;

}

.code {

width: 50%;

height: 35px;

border: 0;

border-color: transparent;

font-size: 16px;

border-radius: 5px;

padding-left: 8px;

}

.code_pic {

display: block;

width: 40%;

height: 35px;

background-color: #34495e;

color: #FFF;

position: absolute;

top: 0px;

left: 60%;

border-radius: 5px;

text-align: center;

}

.name {

margin-top: 20px;

}

.sbm_btn {

text-align: center;

background-color: #1abc9c;

color: #fff;

line-height: 35px;

}

.re_pwd {

width: 25%;

margin: 10px auto 10px;

}

.re_pwd a {

text-decoration: none;

font-size: 14px;

color: #ccc;

}

.re_pwd a:hover {

cursor: pointer;

color: #16A085;

}

.errorTips {

width: 70%;

color: red;

font-size: 14px;

margin: 0 auto;

height: 20px;

line-height: 20px;

}

// 声明一个变量用于存储生成的验证码

document.getElementById(‘code’).οnclick=changeImg;

functionchangeImg(){

// 验证码组成库

vararrays=newArray(

‘1’,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’0′,

‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,

‘k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,

‘u’,’v’,’w’,’x’,’y’,’z’,

‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,

‘K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,

‘U’,’V’,’W’,’X’,’Y’,’Z’

);

// 重新初始化验证码

code=”;

// 随机从数组中获取四个元素组成验证码

for(vari=0; i<4; i++){

// 随机获取一个数组的下标

varr=parseInt(Math.random()*arrays.length);

code+=arrays[r];

}

// 验证码写入span区域

document.getElementById(‘code’).innerHTML=code;

}

// 验证验证码

functioncheck(){

varerror;

// 获取用户输入的验证码

varcodeInput=document.getElementById(‘codeInput’).value;

if(codeInput.toLowerCase() ==code.toLowerCase()){

console.log(‘123’);

returntrue;

}else{

error=’验证码错误,重新输入’;

document.getElementById(‘errorTips’).innerHTML=error;

returnfalse;

}

}

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值