• 阻止浏览器自动填入账号和密码


    方法:

    /**
            *
            * 禁止浏览器自动填充密码
            *
            * @method disabledRememberPassword
            * @param {any} el 目标(可多个)
            *
            */
            function disabledRememberPassword(el) {
                var _el = typeof el === 'object' ? el : $(el);
                if (!_el || _el.length == 0)
                    return;
                _el.each(function (index, item) {
                    $(item).attr('ilength', 0).attr('autocomplete', 'off').attr('type', 'text').attr('readonly', 'readonly').val('').on('focus', function () {
                        this.type != 'password' ? this.type = 'password' : 1;
                    }).on('mouseout', function () {
                        this.setAttribute('readonly', 'readonly');
                    }).on('mouseover', function () {
                        this.removeAttribute('readonly');
                    }).on('input', function () {
                        this.setAttribute('ilength', this.value.length > item.attributes['ilength'].value ? ++item.attributes['ilength'].value : --item.attributes['ilength'].value);
                    });
                    var clear = () => {
                        !item.value ? setTimeout(check, 500) : (item.value = '', setTimeout(clear, 100));
                    };
                    var check = () => {
                        item.value.length != item.attributes['ilength'].value ? (item.setAttribute('ilength', 0), item.value.length == 0 ? setTimeout(check, 500) : (layer.tips('检测到密码输入异常,已自动拦截', item, {
                            tips: [2, '#000000'],
                            time: 2000
                        }), clear())) : setTimeout(check, 500);
                    };
                    check();
                });
            }

    使用:

    //单个
    disabledRememberPassword('#password');
    //多个
    disabledRememberPassword('#password,#repassword');
  • 相关阅读:
    微信app支付,服务端对接
    git 忽略文件权限
    linux 终端全局代理设置
    centos 谷歌浏览器安装
    putty快速设置本地代理
    centos rpmforge repo
    mysql 同步
    apscheduler 排程
    tornado 排程
    gedit 格式化json
  • 原文地址:https://www.cnblogs.com/daicw/p/12049177.html
Copyright © 2020-2023  润新知