diff --git a/src/website/index.html b/src/website/index.html index b36d213..45a1ae4 100644 --- a/src/website/index.html +++ b/src/website/index.html @@ -10,7 +10,16 @@
- + +

diff --git a/src/website/scripts/Main.js b/src/website/scripts/Main.js index 41e173a..ee6180f 100644 --- a/src/website/scripts/Main.js +++ b/src/website/scripts/Main.js @@ -51,6 +51,23 @@ function stopCalibration() { } function startSending() { + textInput.setCustomValidity(""); + // Validate the input + if (!textInput.checkValidity()) { + + console.log(textInput.validity); + if (textInput.validity.valueMissing) { + textInput.setCustomValidity("Please enter between 1 and 16 characters."); + } + + if (textInput.validity.patternMismatch) { + textInput.setCustomValidity("Please only enter valid ASCII characters."); + } + + textInput.reportValidity(); + return; + } + startSendingButton.classList.add(hideClass); stopSendingButton.classList.remove(hideClass); Utility.setMessage(`Sending message: ${textInput.value}`);