add port number validation

This commit is contained in:
Antony Leons 2023-09-14 18:34:31 +01:00
parent cdad0469f2
commit 150266767d
1 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,17 @@
<script type = "text/javascript" th:src = "@{/js/globals.js}"></script>
<script type = "text/javascript" th:src = "@{/js/setup.js}"></script>
<script type = "text/javascript" th:inline = "javascript"> globalsInitialization(); </script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var input = document.getElementById('port');
input.addEventListener('input', function() {
this.value = this.value.replace(/[^0-9]/g, ''); // Remove all non-numeric characters
if (this.value.length > 5) {
this.value = this.value.slice(0, 5); // Limit to 5 digits
}
});
});
</script>
</head>
<body id = "background">
<script type = "text/javascript" th:inline = "javascript"> backgroundInitialization(); </script>