SharePoint Search Box Not Firing When Enter Pressed in IE

Ran into an issue in SP2013/SP2010 where the Enter/Return key would default to other page elements instead of taking the keywords and conducting the search if the Enter key was pressed. So for example, if there was a button on the page, it would fire that element, instead of the search box. Here is a simple bit of jQuery which will ensure that the user’s search gets completed:

//fix for IE 11 Enter/Return key not firing for Search box
jQuery("input[id^=ctl00_PlaceHolderSearchArea]").keypress(function(event){
  if(event.which == 13) 
  {
    window.location = jQuery("a[id^=ctl00_PlaceHolderSearchArea]").attr('href');
   }		        
});
Posted in SharePoint 2010, SharePoint 2013.

Leave a Reply

Your email address will not be published. Required fields are marked *