├── README.md └── jquery.disable-autofill.js /README.md: -------------------------------------------------------------------------------- 1 | # jquery.disable-autofill 2 | Disable Chrome's autofill. Handy for CRUD forms, when you don't want username/password inputs to be autofilled by the browser. 3 | 4 | Usage: 5 | ``` 6 |
10 | 11 | 12 | 15 | ``` 16 | -------------------------------------------------------------------------------- /jquery.disable-autofill.js: -------------------------------------------------------------------------------- 1 | ;(function($, window, document, undefined) { 2 | 3 | var pluginName = 'disableAutofill'; 4 | var defaults = {}; 5 | 6 | function Plugin(element, options) { 7 | this.element = element; 8 | this.options = $.extend({}, defaults, options) ; 9 | 10 | this._defaults = defaults; 11 | this._name = pluginName; 12 | 13 | this.initialize(); 14 | } 15 | 16 | Plugin.prototype.initialize = function() { 17 | var $element = $(this.element); 18 | $element 19 | .val($element.attr('value')) 20 | .clone() 21 | .removeAttr('id class required') 22 | .insertBefore(this.element) 23 | .hide(); 24 | }; 25 | 26 | $.fn[pluginName] = function(options) { 27 | return this.each(function() { 28 | if (!$.data(this, 'plugin_' + pluginName)) { 29 | $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); 30 | } 31 | }); 32 | }; 33 | 34 | })(jQuery, window, document); 35 | --------------------------------------------------------------------------------