method:
/** * * Prohibit browser autofill passwords * * @method disabledRememberPassword * @Param {any} el target (-s) * */ function disabledRememberPassword(el) { var _The = typeof the === ' object ' ? the: $ (the); if (! _The _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)); }; was check = () => { item.value.length = item.attributes [! ' the iLength ' ] .Value (item.setAttribute (? ' the iLength ' , 0 ), item.value.length == 0 the setTimeout (Check,? 500 ): (layer.tips ( ' detects abnormality password, automatically intercept ' , Item, { tips: [2, '#000000'], time: 2000 }), clear())) : setTimeout(check, 500); }; check(); }); }
use:
//单个 disabledRememberPassword('#password'); //多个 disabledRememberPassword('#password,#repassword');