动态显示图形验证码

图形验证码与username绑定,当password输入错误记录一次,错误次数达到预设值时显示图形验证码,要求输入图形验证码才能继续登录。

输入错误次数绑定到用户身上,当正确登录后,清除用户身上记录的密码错误次数。

使用<label for="id">指向username的input标签的id。

<label for="username"></label>

<form:input  id="username"/>

对username做焦点事件focus.

focus主要对当前用户校验是否需要展示图形验证码,如果已经显示要对验证码刷新。

再对username做焦点离开事件blur

blur事件在用户输入完用户名后,离开username,触发事件,校验当前用户是否需要显示图形验证码。

$(function(){

$("#username").focus();

扫描二维码关注公众号,回复: 4809642 查看本文章

    if (showImageCode == "true"){

     refreshCode();

     showRandomCode();

    } else {

      checkShowCaptcha();

    }

$("#username").blur(function(){

     if (showImageCode != "true"){

     checkShowCaptcha();

     }

    });

});

猜你喜欢

转载自blog.csdn.net/qq_28600087/article/details/82892963