Muralidharan BS
Mega Sage
Mega Sage

Disallow emojis in this conversation

 

VA includes a feature called Text input format. This helps ensure that users enter information in the correct format. For example, an email address field might require an "@" symbol and a period (".") to be considered valid. If someone enters something that doesn't meet these requirements, the form will display a message explaining the issue. This helps users avoid submitting incorrect data and prevents frustration down the line.

 

 

find_real_file.png

 

Choosing "Text" as the format permits emojis, but there's no built-in way to exclude them. Fortunately, a simple regular expression can effectively remove emojis from the text. Select the custom option and write the logic to reject code.

 

Option to promt user to enter text again.

function validate(value) {

    var inputText = value; // user input value

    var emojiRegex = /([\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g; // regex using unicode to reject emojis

    var filteredText = inputText.match(emojiRegex, ""); // check if user input has emoji

    var isValid = filteredText === null; // if filteredtext is null then no emoji
    
    return {
            valid: isValid,
            error: isValid ? undefined : "Sorry, emoji's are not allowed"
    };

}

 

MuralidharanBS_0-1719315017880.png

 

To remove emoji from user's input without promting - instead of inputText.match(regex, "") use inputText.replace(regex, "")

 

MuralidharanBS_1-1719315640035.png

 

 

 

Thanks,

Murali

Comments
jamesjimi
Giga Contributor
I think it is difficult to save this setting, but emojisvilla website can help you in this matter.
Version history
Last update:
‎06-25-2024 04:41 AM
Updated by:
Contributors