Validate input field
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
87c748812a
commit
436e261fa7
2 changed files with 27 additions and 1 deletions
|
@ -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}`);
|
||||
|
|
Reference in a new issue