Если у вас есть строка, синтаксис будет str.search ('searchvalue') и будет возвращать начальный индекс в том месте строки, где найдено это значение.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search
Некоторые изменения в вашем коде должны исправить проблему.
<form>
<input type="text" id="userInput" />
<div id="info">
Maecenas dolor nulla, eleifend nec varius eu, consequat at elit. Proin facilisis enim sit amet ligula consectetur scelerisque. Quisque hendrerit pulvinar odio non auctor. Nulla volutpat porttitor felis, non semper lectus rhoncus vitae. Donec finibus at lectus ac dapibus. Aenean mollis erat vitae neque euismod ornare. Nullam in nunc id tellus porttitor tristique. Pellentesque commodo aliquam auctor.
</div>
<button type="button" onclick="search()">Search</button>
<div id="results">
</div>
</form>
<script type="text/javascript">
function search(){
// assume source is the element that contains the text the user is searching
var source = document.getElementById("info").innerHTML;
// input is a textbox or entry element, so we get the value as string
var input = document.getElementById("userInput").value;
// determine the index of the user input, -1 means no match
var action = source.search(input);
// populate a results element on the page with the results of the search
if (action > -1){
document.getElementById("results").innerHTML = "found!";
}else{
document.getElementById("results").innerHTML = "not found!"
}
}
</script>