The html code:
<input type="text" value="" id="txt_serial">
<input type="button" value="gerar" id="botao_serial">
Import jquery:
<scritp src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
Thecodeusingjquery:
functiongeraSerial(){vartext="";
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());
});
});
Result:
link