Jaap Marcus 2 лет назад
Родитель
Сommit
2cff0a352c
2 измененных файлов с 10 добавлено и 0 удалено
  1. 2 0
      web/js/src/index.js
  2. 8 0
      web/js/src/trimInput.js

+ 2 - 0
web/js/src/index.js

@@ -24,6 +24,7 @@ import handleStickyToolbar from './stickyToolbar';
 import handleSyncEmailValues from './syncEmailValues';
 import handleTabPanels from './tabPanels';
 import handleToggleAdvanced from './toggleAdvanced';
+import trimInput from './trimInput';
 import handleUnlimitedInput from './unlimitedInput';
 import initRrdCharts from './rrdCharts';
 import initWebTerminal from './webTerminal';
@@ -51,6 +52,7 @@ function initListeners() {
 	handleSyncEmailValues();
 	handleTabPanels();
 	handleToggleAdvanced();
+	trimInput();
 	initRrdCharts();
 	initWebTerminal();
 }

+ 8 - 0
web/js/src/trimInput.js

@@ -0,0 +1,8 @@
+//trim leading / trailing spaces form input fields
+export default function trimInput() {
+	document.querySelectorAll('input[type="text"]').forEach((input) => {
+		input.addEventListener('change', function () {
+			this.value = this.value.trim();
+		});
+	});
+}