add message for emojis not supported on this type
parent
c5ed804d9f
commit
42e7f6da4b
|
@ -550,9 +550,20 @@
|
|||
}
|
||||
|
||||
function SHX_IFC_genTextInput(inputID, labelText, inputName, inputVal, section_id, maxLength = 24, emojisSupported = false) {
|
||||
setTimeout(() => {
|
||||
console.log("tim", document.querySelector(`#${inputID}`).value)
|
||||
// Regular expression to match emoji characters
|
||||
const emojiRegex = /[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F700}-\u{1F77F}]|[\u{1F780}-\u{1F7FF}]|[\u{1F800}-\u{1F8FF}]|[\u{1F900}-\u{1F9FF}]|[\u{1FA00}-\u{1FA6F}]|[\u{1FA70}-\u{1FAFF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|[\u{2B50}-\u{2B55}]|[\u{1F1E6}-\u{1F1FF}]/u;
|
||||
|
||||
// helper function to check if string contains emoji on product variant which not support emojis
|
||||
function showErrorMessageIfEmojiNotSupported(value) {
|
||||
if (!emojisSupported && value.length > 0 && emojiRegex.test(value)) {
|
||||
document.querySelector(`label[for="${inputID}-label"] span`).textContent = 'Emojis werden bei diesem Typ nicht unterstützt. Bitte wechsle zu "Mit Hintergrund"';
|
||||
document.querySelector(`label[for="${inputID}-label"] span`).style.color = 'red';
|
||||
}
|
||||
}
|
||||
|
||||
showErrorMessageIfEmojiNotSupported(document.querySelector(`#${inputID}`).value)
|
||||
|
||||
setTimeout(() => {
|
||||
document.querySelector(`#${inputID}`).addEventListener('input',(e)=>{
|
||||
if(!document.querySelector(`label[for="${inputID}-label"] span`)){
|
||||
const span = document.createElement("span");
|
||||
|
@ -567,15 +578,7 @@
|
|||
document.querySelector(`label[for="${inputID}-label"] span`).style.color = 'red';
|
||||
}
|
||||
|
||||
if (!emojisSupported && e.target.value.length > 0) {
|
||||
// Regular expression to match emoji characters
|
||||
const emojiRegex = /[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F700}-\u{1F77F}]|[\u{1F780}-\u{1F7FF}]|[\u{1F800}-\u{1F8FF}]|[\u{1F900}-\u{1F9FF}]|[\u{1FA00}-\u{1FA6F}]|[\u{1FA70}-\u{1FAFF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|[\u{2B50}-\u{2B55}]|[\u{1F1E6}-\u{1F1FF}]/u;
|
||||
|
||||
if (emojiRegex.test(e.target.value)) {
|
||||
document.querySelector(`label[for="${inputID}-label"] span`).textContent = 'Emojis werden bei diesem Typ nicht unterstützt. Bitte wechsle zu "Mit Hintergrund"';
|
||||
document.querySelector(`label[for="${inputID}-label"] span`).style.color = 'red';
|
||||
}
|
||||
}
|
||||
showErrorMessageIfEmojiNotSupported(e.target.value)
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
|
|
Loading…
Reference in New Issue