1

I have a webpage having an input field of type text. The input text is kept hidden. I have to get the value through barcode scanner in the input field. Whenever I need to get input through scanner, I need to set focus on input field and if I set the focus on input, virtual keyboard on mobile browser appears.

$(document).ready(function() {

  $('#partsIdScan').on('input', function() {
    $('#result').html('$(#partsIdScan').val();
    $('#partsIdScan').val('');
  });
});

//To set focus on input
$(document).on('click', function(e) {
  e.preventDefault();
  if (e.target.id != 'parstIdScan') {
    $('#partsIdScan').focus();
  }

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id='partsIdScan' type='text' , name='partsIdScan' , autofocus />
<h3 id='result'></h3>

Is it possible to set focus always on input field without opening the virtual keyboard on mobile browser?

nmak18
  • 734
  • 5
  • 20
Krish
  • 21
  • 3
  • this post might help https://stackoverflow.com/questions/8335834/how-can-i-hide-the-android-keyboard-using-javascript – nmak18 Sep 07 '19 at 13:24
  • @nmak18 Thank you for your reply. But unfortunately the link did not help me. I have to make the input field enabled always even if clicked on docuement. – Krish Sep 08 '19 at 05:30

0 Answers0