convert content to input

2

I use a script in javascript to convert everything I type, from input to uppercase.

But I have a specific input where I can not change its content. How can I do this?

Follow the code:

// Converte minusculas em maiusculas
$(document).ready(function() {
  $('input').on('input', function() {

    // Armazena posição corrente do cursor
    var start = this.selectionStart,
      end = this.selectionEnd;
    this.value = this.value.toUpperCase();

    // Restaura posição armazenada anteriormente.
    this.setSelectionRange(start, end);
  });
});
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<input type='text' name='video'>
<input type='text' name='video'>
<input type='text' name='video'>
<input type='text' name='video'>


<input type='text' name='nao_alterar'>
    
asked by anonymous 16.06.2016 / 21:56

1 answer

0

Create an event that runs on all inputs except the one whose name is nao_alterar . Make:

$('input').not('[name="nao_alterar"]').on('input', function() {

// Armazena posição corrente do cursor
var start = this.selectionStart,
  end = this.selectionEnd;
this.value = this.value.toUpperCase();

// Restaura posição armazenada anteriormente.
this.setSelectionRange(start, end);
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype='text'name='video'><inputtype='text'name='video'><inputtype='text'name='video'><inputtype='text'name='video'><inputtype='text'name='nao_alterar'placeholder="não alterar">
    
16.06.2016 / 22:17