Change between keyboard types (text - numbers)

Asked

Viewed 26 times

1

Good night. I am developing an application (Cordova), that the user has to register an initial code with 2 (two) letters, 14 (fourteen) numbers and more 2 letters.

I was able to make the input change to numeric when it reaches the second letter, but the keyboard doesn’t change the type of data. I gave a . Blur() and a . Focus(), but the keyboard does not reappear.

Any suggestions?

var espaco = 0;
$('#numeroOS').keyup(function(e) {

if (e.keyCode == 8 || e.keyCode == 46) {
  espaco = 0;
  $('#numeroOS').val("");
}

var text = $('#numeroOS').val();

if (text[text.length - 1] != ' ') {
  text.length - espaco;
} else {
  espaco++;
}

if (text.length == 2){
  $('#numeroOS').prop('type', 'tel');
  $('#numeroOS').blur();
  setTimeout(function(){
    $('#numeroOS').focus();
  },100);     

} else {
  $('#numeroOS').prop('type', 'text');
}
  • 1

    instead of just giving the Blur, you tried to focus on another element and then return to your input?

  • I didn’t try this not, but something I saw, that focusing on the element, does not open the keyboard.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.