zoukankan      html  css  js  c++  java
  • 阻止浏览器自动填入账号和密码

    方法:

    /**
            *
            * 禁止浏览器自动填充密码
            *
            * @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');
  • 相关阅读:
    PHP 数据类型
    PHP SAPI
    PHP 基础架构
    PHP7的变化
    mysql 选择优化的数据类型需要注意的几点
    彻底删除在github上提交的文件
    php7 新特性
    php缓冲区 一些笔记
    设计模式 一些概念
    mysql性能优化其中一部分小结
  • 原文地址:https://www.cnblogs.com/daicw/p/12049177.html
Copyright © 2011-2022 走看看