jQuery Mobile focus next input on keypress

Posted by user738175 on Stack Overflow See other posts from Stack Overflow or by user738175
Published on 2011-05-04T20:25:33Z Indexed on 2012/10/02 9:38 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

I have a jquery mobile site with a html form consisting of 4 pin entry input boxes. I want the user to be able to enter a pin in each input field without having to press the iphone keyboards "next" button. I have tried the following and although it appears to set the focus to the second input and insert the value, the keyboard disappears so the user still has to activate the required input with a tap event.

$('#txtPin1').keypress(function() {
        $('#txtPin1').bind('change', function(){  
            $("#txtPin1").val($("#txtPin1").val()); 
        });
        $("#txtPin2").focus();
        $("#txtPin2").val('pin2');
});

Is there a different event that I should be assigning to $("#txtPin2")?

I have tried to implement http://jqueryminute.com/set-focus-to-the-next-input-field-with-jquery/ this also, but I found that it worked for android and not for iphone.

Any help is greatly appreciate it.

© Stack Overflow or respective owner

Related posts about input

Related posts about focus