add message for emojis not supported on this type

main
alexanderroese 2024-07-25 22:21:21 +02:00
parent ec27a08ebc
commit 158cbde63a
1 changed files with 15 additions and 3 deletions

View File

@ -567,7 +567,17 @@
} }
} }
function createInputLabelIfNotExists(inputID) {
if (!document.querySelector(`label[for="${inputID}-label"] span`)) {
const span = document.createElement("span");
span.style.marginLeft = `10px`
document.querySelector(`label[for="${inputID}-label"]`).appendChild(span)
}
}
setTimeout(() => { setTimeout(() => {
createInputLabelIfNotExists(inputID)
showErrorMessageIfEmojiNotSupported(document.querySelector(`#${inputID}`).value, inputID) showErrorMessageIfEmojiNotSupported(document.querySelector(`#${inputID}`).value, inputID)
/* /*
const event = new Event('input', { const event = new Event('input', {
@ -578,11 +588,13 @@
document.querySelector(`#${inputID}`).dispatchEvent(event); */ document.querySelector(`#${inputID}`).dispatchEvent(event); */
document.querySelector(`#${inputID}`).addEventListener('input', (e) => { document.querySelector(`#${inputID}`).addEventListener('input', (e) => {
if (!document.querySelector(`label[for="${inputID}-label"] span`)) { createInputLabelIfNotExists(inputID)
/*if (!document.querySelector(`label[for="${inputID}-label"] span`)) {
const span = document.createElement("span"); const span = document.createElement("span");
span.style.marginLeft = `10px` span.style.marginLeft = `10px`
document.querySelector(`label[for="${inputID}-label"]`).appendChild(span) document.querySelector(`label[for="${inputID}-label"]`).appendChild(span)
} } */
document.querySelector(`label[for="${inputID}-label"] span`).style.display = `inline` document.querySelector(`label[for="${inputID}-label"] span`).style.display = `inline`
document.querySelector(`label[for="${inputID}-label"] span`).style.color = null; document.querySelector(`label[for="${inputID}-label"] span`).style.color = null;
document.querySelector(`label[for="${inputID}-label"] span`).textContent = e.target.value.length + ' von ' + maxLength + ' Zeichen verwendet'; document.querySelector(`label[for="${inputID}-label"] span`).textContent = e.target.value.length + ' von ' + maxLength + ' Zeichen verwendet';