I want to stop a form submit button from reloading a page. This works in Firefox 3.6, Safari 5, and Opera. But Chrome 5 does not prevent the link.
Here is the form.
<form class="container_7" id="find-store-all" action=" ">
<label for="customer-loc" class="grid_3">Find a Store Near You:</label>
<input name="customer-loc" id="customer-loc" class="grid_3" type="text" placeholder="zip code or address" />
<button type="submit" id="customer-loc-sub" class="grid_1" >Enter</button>
</form>
I am using event delegation to manage the click. Here is the JavaScript.
document.onclick = handleClick;
function handleClick(e){
if(!e) var e = window.event;
var target = e.target || e.srcElement;
switch(target.id){
case "customer-loc-sub" :
e.preventDefault();
findClosestStoreOne();
break;
}
}
Any suggestions would be appreciated.