0

I'm facing a strange problem when working with text fields in HTML.

I have two text fields "username_1" and "username_2", the username_1 will show when the app in portrait mode, and username_2 for landscape mode.

Okay, now i entered some value in "username_1" field consider as SSSSS, and i change the orientation, when i change the orientation am making "username_1" is blur, hide and making focus on "username_2", i set the value of "username_1" to "username_2". Now am in "username_2" field, and "username_2" value is SSSSS.

Now, if i start entering some values in "username_2" field consider as RRRRR , its appending from starting(RRRRRSSSSSS) instead of adding as in back(SSSSSRRRRRR).

$("#username_1").blur();
$("#username_1").hide();
$("#username_2").val($("#username_1").val());
$("#username_2").show();
$("#username_2").focus();

Please bare grammatical mistakes, please provide suggestions !!!

Thanks.

Sriram90
  • 63
  • 1
  • 1
  • 7

2 Answers2

0

your cursor in the text fields of html are at position zero. try and move it to the end of the content within it using some function(to move the cursor in text field)

P.S. I haven't used phonegap so m unable to tell the function name.

7bluephoenix
  • 958
  • 7
  • 18
0

Maybe it's stupid but if you try to focus before set the username_2 value ?

$("#username_1").blur();
$("#username_1").hide();
$("#username_2").show();
$("#username_2").focus();
$("#username_2").val($("#username_1").val());

Or take a look at this solution : place caret at end

Community
  • 1
  • 1
gaepi
  • 404
  • 3
  • 14
  • No luck :( i think there is no big difference between those – Sriram90 Jun 20 '13 at 15:01
  • Hi @gaepi , i tried your above link .. actually in my case carel placing in the end perfectly, if i start to type its coming from starting ... – Sriram90 Jun 20 '13 at 15:33