user8507737
user8507737

Reputation:

Textbox enter key alternative for mobile device

I have a textbox for entering details

<input type="text" class="textbox" id="myText"/>

and I like to save the entered details when the Enter key is pressed. I can achieve that with the following code.

$('#myText').live("keypress", function(e) {
      if (e.keyCode == 13) {
          alert("Enter pressed");
          -- code for saving
      }
});

But if I use a mobile device, I won't be able to press the Enter key. How do I get this feature in the same?

I want it to be able to use in both computer and mobile devices, and this is not a form submit, because I have some other textboxes too.. I want to save the only textbox in which enter key is pressed

Upvotes: 1

Views: 558

Answers (1)

Dinesh Hebbar
Dinesh Hebbar

Reputation: 68

Try using the onchange method,

$('#myText').change(function(e) {
      alert("Value changed");
      -- code for saving
    }
});

Upvotes: 2

Related Questions