Skip to content

Commit ff8ec2b

Browse files
authored
Merge pull request hestiacp#4293 from hestiacp/feature/js-trim-spaces
Trim leading en trailing spaces
2 parents d6c8f35 + 7ea3cb9 commit ff8ec2b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

web/js/src/autoTrimInputs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//trim leading / trailing spaces form input fields
2+
export default function handleAutoTrimInputs() {
3+
document.querySelectorAll('input[type="text"]').forEach((input) => {
4+
input.addEventListener('change', function () {
5+
this.value = this.value.trim();
6+
});
7+
});
8+
}

web/js/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import alpineInit from './alpineInit';
22
import focusFirstInput from './focusFirstInput';
33
import handleAddIpLists from './addIpLists';
4+
import handleAutoTrimInputs from './autoTrimInputs';
45
import handleConfirmAction from './confirmAction';
56
import handleCopyCreds from './copyCreds';
67
import handleClipboardCopy from './clipboardCopy';
@@ -33,6 +34,7 @@ focusFirstInput();
3334

3435
function initListeners() {
3536
handleAddIpLists();
37+
handleAutoTrimInputs();
3638
handleConfirmAction();
3739
handleCopyCreds();
3840
handleClipboardCopy();

0 commit comments

Comments
 (0)