Last active
December 18, 2015 15:39
-
-
Save Jerph/5806096 to your computer and use it in GitHub Desktop.
jQuery plugin to trim text inputs on change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| * jquery.trimTextInputs.js v1.0.0 | |
| * | |
| * Copyright 2013, Jeff Fendley | |
| * Dual licensed under the MIT or GPL Version 2 licenses. | |
| * | |
| */ | |
| (function ($) { | |
| // Trims text inputs on change | |
| $.extend({ | |
| trimTextInputs: function (options) { | |
| var exceptionsSelector = (options && options.exceptionsSelector) || '[data-no-trim]'; | |
| var selector = 'input:text:not(' + exceptionsSelector + '),textarea:not(' + exceptionsSelector + ')'; | |
| $('form').on('change', selector, function () { | |
| $(this).val($.trim($(this).val())); | |
| }); | |
| } | |
| }); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment