Having worked for quite a while on creating the new VTO2 website I sent it around a while ago to my supervisors to see what they thought. Imagine my disappointment when one of them replied that they couldn’t get the fancy AJAX search engine to work. I double checked everything and couldn’t for the life of me figure out why it wasn’t working on her machine. I don’t remember how I realised it but it became apparent that when she had typed a search pattern in she then pressed ‘enter’ / ‘return’. This was bit of a ‘duh’ moment for me. I had myself been so fascinated by the AJAX LiveSearch abilities that I had managed to create that I hadn’t stopped to think that one of the first reactions most people will have to a search-box is most naturally to press ‘enter’.
So I searched the web far and wide and came up with no solution. I then decided to make sure that when ‘enter’ submitted the form it just went back to the same page allowing the user to begin again. I then added a request below asking that the user did not press ‘enter’ while doing a search.
But then today while I was moving the whole website to a new (and yeah – much faster) server it struck me to search for “ajax deactivate enter”. Up came this post about “Disable form submit on enter keypress” written by Slobodan Kovacevic in 2005.
I did as he suggests and ‘hey presto’ it worked in Firefox, Safari and I presume IE (although I haven’t checked this yet). I was amazed because normally when I have small but very significant issues like that it takes ages to find the answer. But not this time.