Home > Software engineering >  Iterate through textarea fields under a specific class to strip emojis from a textarea field whose n
Iterate through textarea fields under a specific class to strip emojis from a textarea field whose n

Time:04-12

I'm looking only for a pure JavaScript solution to the problem I'm trying to fix with the code and the logic below. I'm stuck being unable to get the value of the textarea field whose name contains Gift Message as a substring of its name. Could you please help fix this?

The HTML is as follows:

<span >
    <textarea name="properties[Enter Gift Message Below. NO EMOJIS PLEASE. Remember to sign your name! ]"  maxlength="1000">
    </textarea>
  <textarea name="properties[Test Gift ]"  maxlength="1000">
    </textarea>
</span>

JavaScript:

<script>
    {%- comment -%}
        This block of code checks if emojis are present in gift message, on keyup event
        Logic:
        1. Get value of textarea field for gift message.
        2. Get the textarea "bold_option_element" fields whose name has "GiftMessage" after stripping all blanks.
        3. Return false if emojis are present.
        Refer: https://melvingeorge.me/blog/check-if-string-contain-emojis-javascript for emoji validation
    {%- endcomment -%}
    window.onkeyup = function(e) {
        // Get gift message string.
        giftMessage = "Hello            
  • Related