diff --git a/app/code/Magento/Customer/view/frontend/templates/form/login.phtml b/app/code/Magento/Customer/view/frontend/templates/form/login.phtml
index 77e250c5de923..2d44dde215139 100644
--- a/app/code/Magento/Customer/view/frontend/templates/form/login.phtml
+++ b/app/code/Magento/Customer/view/frontend/templates/form/login.phtml
@@ -24,7 +24,7 @@
@@ -43,12 +43,3 @@
-
diff --git a/app/code/Magento/Customer/view/frontend/web/js/trim-username.js b/app/code/Magento/Customer/view/frontend/web/js/trim-username.js
deleted file mode 100644
index 1b6aab6086853..0000000000000
--- a/app/code/Magento/Customer/view/frontend/web/js/trim-username.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-define([
- 'jquery'
-], function ($) {
- 'use strict';
-
- $.widget('mage.trimUsername', {
- options: {
- cache: {},
- formSelector: 'form',
- emailSelector: 'input[type="email"]'
- },
-
- /**
- * Widget initialization
- * @private
- */
- _create: function () {
- // We need to look outside the module for backward compatibility, since someone can already use the module.
- // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the email field from the
- // newsletter email field or any other "email" field.
- this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector);
- this._bind();
- },
-
- /**
- * Event binding, will monitor change, keyup and paste events.
- * @private
- */
- _bind: function () {
- if (this.options.cache.email.length) {
- this._on(this.options.cache.email, {
- 'change': this._trimUsername,
- 'keyup': this._trimUsername,
- 'paste': this._trimUsername
- });
- }
- },
-
- /**
- * Trim username
- * @private
- */
- _trimUsername: function () {
- var username = this._getUsername().trim();
-
- this.options.cache.email.val(username);
- },
-
- /**
- * Get username value
- * @returns {*}
- * @private
- */
- _getUsername: function () {
- return this.options.cache.email.val();
- }
- });
-
- return $.mage.trimUsername;
-});
diff --git a/lib/web/mage/trim-input.js b/lib/web/mage/trim-input.js
new file mode 100644
index 0000000000000..371c2dc3309e4
--- /dev/null
+++ b/lib/web/mage/trim-input.js
@@ -0,0 +1,61 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+ 'jquery'
+], function ($) {
+ 'use strict';
+
+ $.widget('mage.trimInput', {
+ options: {
+ cache: {}
+ },
+
+ /**
+ * Widget initialization
+ * @private
+ */
+ _create: function () {
+ this.options.cache.input = $(this.element);
+ this._bind();
+ },
+
+ /**
+ * Event binding, will monitor change, keyup and paste events.
+ * @private
+ */
+ _bind: function () {
+ if (this.options.cache.input.length) {
+ this._on(this.options.cache.input, {
+ 'change': this._trimInput,
+ 'keyup': this._trimInput,
+ 'paste': this._trimInput
+ });
+ }
+ },
+
+ /**
+ * Trim value
+ * @private
+ */
+ _trimInput: function () {
+ var input = this._getInputValue().trim();
+
+ this.options.cache.input.val(input);
+ },
+
+ /**
+ * Get input value
+ * @returns {*}
+ * @private
+ */
+ _getInputValue: function () {
+ return this.options.cache.input.val();
+ }
+ });
+
+ return $.mage.trimInput;
+});
+