1

I am required to find for a specific word in a text input whereby the word is the "+" symbol. The users for my program uses IE8 and IE11 and unfortunately when I looked in w3schools, I found out that the includes() method is not supported in Internet Explorer 11 (or earlier). Below is my code:

<input type="text" class="recycle" name="txtEXT_AK" id="txtEXT_AK" size="10" onclick="this.select()">

document.getElementsByClassName("recycle").onkeyup = function(){checker()}

function checker(){
    var text_value=document.getElementsByClassName("recycle");
    word="+";
    
    var textValue = text_value.value;
    
    if (textValue.includes(word))
    {
      alert('found')
    }   
}

So far, there is no alert() coming out when I tried to enter the "+" symbol into the text box. Is there any alternative for the includes() method that I can use for the checker code? I have tried indexOf, contains and match but so far there is no luck. Any help is really appreciated!

Naz Azhar
  • 75
  • 8

1 Answers1

0

Actually,the key bug is not "includes", you should change getElementsByClassName('recycle') to getElementById('txtEXT_AK')

Nitheesh
  • 19,238
  • 3
  • 22
  • 49
oliver34
  • 330
  • 2
  • 7