In HTML5 there is a new input type, \'search\'.
On most browser it\'s just remain to a simple \'text\' input, but for webkit based browsers, it adds a little cross to reset
You could add a condition to check if the contents of the search field are empty but this is all no good even with a timeout because it runs the code first then clears the box.
The other problem is that the code would not react to the close button when you are editing the field