I have a texbox and textarea. See below. Enter a word in the "first" textbox that you want to check. Next, start typing in the "second" box. If it finds a match for the word in the first box, it will show a message.
The script.
<body>
<p>Word to check... <input type="text" value="the" id="tb" /></p>
<p>
<textarea onkeyup='findWord(this)' id='ta' rows="3" cols="40"
placeholder="start typing here..."></textarea>
</p>
<p id="result"></p>
</body>
<script>
let findWord = (el) => {
let wrd_2_find = document.getElementById('tb').value.toLowerCase();
let ta = document.getElementById(el.id).value.toLowerCase();
document.getElementById('result').innerHTML =
ta.includes(wrd_2_find) == true ? 'word exits' : 'no match';
}
</script>includes() method examples:
1) check if a particular word is inside a <div> element
