Sandeep Rao Sandeep Rao - 2 months ago 10
Android Question

Is there any way to capture the android 'GO' button or iPhone 'GO' button in jquery?

I am building a mobile website, In this a form is there but no submit button. So when the user types something in the input field and clicks on Android or iPhone GO button it should submit the form. I'm using HTML and jQuery for this.

How can I capture this GO event in jQuery? I want it to be done this way it self.

Answer

Add a submit-button and set its opacity to 0.

I used this for html:

<form>
    <input type="text" name="input" />
    <input type="submit" style="opacity:0;" />
</form>

And this to alert() the value:

$(document).ready(function() {
    $("form").submit(function() {
        alert($("[name=input]").val());
    });
});

You just need to handle the submit-Event of the form, this works great with jQuery.

Comments