How do I make Jquery Mask not accept numbers?

1

I'm getting a data that would be the first three digits alphabetic characters and the other 4 numeric (A vehicle license plate).

I saw in a site that to receive only letters in Jquey Mask, just use the "A"

Example:

$('.placa').mask('AAA-0000');

But using this example, the user can insert numbers before the hyphen without any problems ...

Does anyone know how I can solve this?

    
asked by anonymous 25.05.2016 / 21:24

1 answer

1

I'm going to try to leave this very complete answer since this question is very interesting and I myself was looking for it some time ago and I believe that other people will also look for it.

In this example only

  • HTML
  • jQuery

Very simple using the jQuery Masked Input plugin, in the example there are 3 fields, one text only, another text and number, and finally just number.

$(function() {
  $('#apenasnumero').mask('(99) 9999-9999');

  $('#apenasletra').mask('aaaaaaaa');

  $('#letrasnumeros').mask('********');
});
<head>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script><!--linkparaoplugindemascara--><scripttype="text/javascript" src="http://tutsmais.com.br/blog/arquivos/mascara/jquery.maskedinput-1.2.2.min.js"></script></head>ApenasLetras:<inputtype="text" id="apenasletra" />
<br>Letras e Números
<input type="text" id="letrasnumeros" />
<br>Apenas Número:
<input type="text" id="apenasnumero" />
<br>

If you have any questions, just comment.

    
25.05.2016 / 21:47