0

I have been asked to 3 times and no answer. please someone could tell me how jquery or javascript can get the value of the input form if typed by virtual keboard like Mottie Virtual Keyboard or JKeyboard (Made by Jquery). Thank you

  • Are you trying to detect change or you just want at any point to get the value? – metal03326 Aug 04 '16 at 10:02
  • any point dude. example i try to add maxlength in textarea, but it's not working if using virtual keyboard. [jsfiddle](https://jsfiddle.net/tmfL6vgm/) , actually I just wanted to add a maxlength in the textarea, but does not work when using the virtual keyboard @metal03326 – Rofi Fathurrohman Aug 04 '16 at 10:03
  • Getting the length doesn't have anything to do with the maxlength. Both keyboards use programmatic way of setting the value to the input, so maxlength won't work. If they don't support it, you can try to modify their code (ugly), request a ticked to add support for it (slow) or do some kind of external code to fix the issue (again ugly). – metal03326 Aug 04 '16 at 10:09

2 Answers2

0

If you are using jkeyboard you can use on click at keyboard . Here is the fiddle https://jsfiddle.net/ashisha/okvo7rak/

  $('#keyboard').on("click", function (e) {
  alert($("#search_field").val())
  }) 
Ashisha Nautiyal
  • 1,389
  • 2
  • 19
  • 39
0

Try this code (demo)

var $input = $('#search_field'),
  maxLength = 10;

$('#keyboard').jkeyboard({
  layout: "azeri",
  input: $input
});

$('.jkey').on("click", function(e) {
  var val = $input.val();
  if (val.length > maxLength) {
    $input.val(val.substring(0, maxLength));
  }
});
Mottie
  • 84,355
  • 30
  • 126
  • 241