How does ER get masquerading an alphanumeric code?

1

I need to mask a 13-character alphanumeric code field while the user types, separated by a hyphen, such as: 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; }

Thanks for the help.

    
asked by anonymous 08.05.2017 / 17:47

1 answer

1

You can use 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><scriptsrc="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 be combinations that beat with [a-zA-Z0-9]

    
08.05.2017 / 18:13