Testing disableAutoFill
jquery.disableAutoFill
by litespeedtdf
HTML
<form id="frmData" method="POST" >
<input id="password" class="disabledAutoFillPassword" type="password" />
</br>
</br>
<div>
<button id="testIt">Test It</button>
<input id="btnClear" type="button" value="Clear"/>
<button id="btnCreate" type="submit">Login</button>
</div>
</br>
</br>
<textarea id="resultValue" rows="20" cols="50"></textarea >
</form>
JavaScript
/**
* Jquery - DisableAutoFill plugin
* The easiest solution for disabling Google Chrome auto-fill, auto-complete functions.
*
* @license MIT
* @version 1.2.3
* @author Terry, https://github.com/terrylinooo/
* @updated 2018-08-01
* @link https://github.com/terrylinooo/jquery.disableAutoFill
*/
(function($) {
var realPassword = [];
var realFields = [];
var _helper = {};
Array.prototype.insert = function (index, item) {
this.splice(index, 0, item);
};
_helper.passwordListener = function(obj, settings) {
var passObj = (settings.passwordFiled == '') ? '.disabledAutoFillPassword' : settings.passwordFiled;
if (obj.find('[type=password]').length > 0) {
obj.find('[type=password]').attr('type', 'text').addClass('disabledAutoFillPassword');
}
$(obj).on('keyup', passObj, function() {
var tmpPassword = $(this).val();
var passwordLen = tmpPassword.length;
// Get current keyup character position.
var currKeyupPos = this.selectionStart;
for (var i = 0; i < passwordLen; i++) {
if (tmpPassword[i] != '*') {
if (typeof realPassword[i] == 'undefined') {
realPassword[i] = tmpPassword[i];
} else {
if (currKeyupPos != passwordLen) {
realPassword.insert(currKeyupPos - 1, tmpPassword[i]);
}
}
}
}
$(this).val(tmpPassword.replace(/./g, '*'));
if (settings.debugMode) {
console.log('Current keyup position: ' + currKeyupPos);
console.log('Password length: ' + passwordLen);
console.log('Real password:');
console.log(realPassword);
}
});
}
/**
* Helper function
* - Replace submit button to normal button to make...