Reputation: 31311
I am using PhoneGap 1.8.1 to build an application in Iphone.
I have an login window (screen shot attached below).
There are two html Text-boxes (one for entering user name and another one for entering password) and a Log-in button to login.
I can able to successfully Login through my Login button using below code.
<input type="button" value="Login" id="btnSubmit" class="blueButton" data-role="none"/>
$("#btnLogin").click(function(){
var username = $("#txtUsername").val();
var password = $("#txtPassword").val();
//do login actions ….
});
I have to trigger the same Login functionality when user taps on iPhone Keyboard "Go" button. However , I am unable to trigger the Login button actions while user taps on the iOS default Keyboard "Go" button.
May i know how can i register/trigger the keyboard "Go" button event in PhoneGap.
I have found the related post in Overloading the IPhone “GO” button
However i didn't find any good answer for that one.
Any help on this issue is Appreciated.
Thanks.
Upvotes: 2
Views: 4171
Reputation: 4568
I had a similar question, but couldn't change my button into a submit - I was using a trigger on click of an img.
But I found that even without a submit button, you can still register the form submit fired by the user clicking the "GO" button, and then do what you need to do.
$(document).on('submit', ".search-form", function(){
runSearch(inputs);
});
I am not sure what would happen if you had multiple forms on a page, but this works for a single form.
Upvotes: 0
Reputation: 7659
Try making your button of type submit
<input type="submit" value="Login" id="btnSubmit" class="blueButton" data-role="none"/>
Or bind event on form submit
$("#loginForm").form(function(){
// do event prevention if required
var username = $("#txtUsername").val();
var password = $("#txtPassword").val();
//do login actions ….
});
Although this issue does not seem related to Phonegap (Cordova) as it should work same in browser as well.
Upvotes: 3