Reputation: 1186
i am trying to trigger a click event on a button whenever user presses 'Go' on android soft-keyboard. any help will be highly appreciated.
<div class="combined_input ui-shadow-inset">
<input type="text" placeholder="Username" id="username" value="" data-mini="true" class="bb_1">
<input type="password" placeholder="Password" id="password" value="" data-mini="true">
</div>
<div data-role="none" class="login">
<input type="button" value="Login" class="ok" id="login-btn" data-mini="true">
</div>
<div data-role="none" class="cancel">
<input type="button" value="Cancel" class="cancel" onClick="exitApp()" data-mini="true">
</div>
when user enters password and presses 'Go' button, i would like to trigger a click event on login-btn
. can that be done?
Regards,
JadeSync.
Upvotes: 3
Views: 3521
Reputation: 545
Try this one.
$(document).ready(function () {
$('#password').on('keyup', function(e) {
var theEvent = e || window.event;
var keyPressed = theEvent.keyCode || theEvent.which;
if (keyPressed == 13) {
$('#login-btn').trigger( 'click' );
}
return true;
});
});
Upvotes: 10