What does the ER look like to mask an Anumeric code?

Asked

Viewed 388 times

1

I need to mask a 13-character alphanumeric code field while the user types, separated by hyphen, for example: 0DF7M3-R34X21

I’m using a function to apply the mask, so it would be applied as follows:

function mask_code(valor) { valor = valor.replace('ER', '$1-$2'); return valor; }

Grateful for the help.

1 answer

1

You can use the Lib jQuery-Mask

// 0DF7M3-R34X21
$('#test').mask('AAAAAA-AAAAAA');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/igorescobar/jQuery-Mask-Plugin/master/src/jquery.mask.js"></script>

<label>Teste :</label>
<input type="text" id="test"/>

In lib A would match combinations that match [a-zA-Z0-9]

Browser other questions tagged

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