There could also be a problem with using search(), since that will return the position of the first occurance of the value you're searching for. If you're searching for "1234" in a string with search() and the string you're searching in starts with "1234", the position returned would be 0, which would make the if statement return false. Probably not what you want.

Even once you get your code the way you need it won't work as you're targeting an element that doesn't exist in the DOM yet as fas as your JavaScript is concerned, you need to execute your <script> code after your <div> otherwise you will get undefined errors if you look in your browsers developer console.