To stop the refresh, simply add an onsubmit clause to your form declaration. The following is taken from my own code that I am working with now.
<form id="postcodeEntry" method="post" action="#" onsubmit="' + this.objName + '.calcRoute(\'driving\',this.postcode.value);return false;">
As long as there is no error in the JavaScript function you call from that clause, the return false, will prevent the page from changing and makes the form a direct interaction with the JavaScript on/in the page.
That will work if any submit buttons are used or the enter key submits the form from the text box.