Android device on jQueryMobile submitting form on return

We recently had an issue confined to Android users in our jQuery mobile application. When users  pressed the return button on an input field the page was submitted to the server. On every other page pressing the return button would instead correctly call the default action of the page.

The Android return button is a little strange and doesn’t have a key code associated with it. The solution was instead to interupt the form submit event:

if (navigator.userAgent.toLowerCase().indexOf(“android”) > -1) {

$(“#myForm).submit(function () {
return false;
});
}

Advertisements