The html code:
<input type="text" value="" id="txt_serial">
<input type="button" value="gerar" id="botao_serial">
Import the jquery:
<scritp src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
The code using jquery:
function geraSerial() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 6; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return "wf2017" + text;
}
$(function(){
$('#botao_serial').click(function(){
$('#txt_serial').val(geraSerial());
});
});
Upshot:
https://jsfiddle.net/wictor/uqs57ugL/1/
Does the Random part have closed length and/or content? or can be any character and any length?
– Sergio
would just be numbers, but with a minimum of 4 numerical guards.
– Jaider Master Info
Possible duplicate of Random number without repetition
– Samuel Rizzon