I am migrating a site from SP2010 to SP2013. One of JS is working on SP2010 mode and not in SP2013 evaluation page.

<input id="SearchBox" value="Search…" onkeypress="if(event.keyCode==13){event.preventDefault();SearchKeyword('/pages/results.aspx','SearchBox',1);alert('triggered');}" onfocus="if(this.value == 'Search…') this.value = '';" onblur="if(this.value == '') this.value = 'Search…';" type="text" />

Expected behaviour (also the behaviour on SP2010 mode): user focus on the "searchbox" textbox, key in some value and press "Enter" on keyword, it will bring him to /pages/results.aspx?k=value .

Behaviour on SP2013 evaluation mode: after user press "Enter" entire page is refreshed and the querystring is not inserted.

How can I troubleshoot this case? The "onfocus" and "onblur" event are working. Also the "triggered" message is prompted when press enter.

I added "event.preventDefault" after some researching. However it does nothing on my function.

  • If the focus is not in Searchbox, press "Enter" will not refresh.
    – Mark L
    Jun 4, 2014 at 10:00

1 Answer 1


The problem is solved by adding [ return false; ] at the end of JavaScript function. Like this:

onkeypress="if(event.keyCode==13){SearchKeyword('/pages/results.aspx','SearchBox');return false;};"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.