Change between keyboard types (text - numbers)

1

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

I was able to make the input change to numeric when it reaches the second letter, but the keyboard does not change the data type. 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');
}
    
asked by anonymous 18.03.2018 / 23:11

0 answers