O código html:
<input type="text" value="" id="txt_serial">
<input type="button" value="gerar" id="botao_serial">
Importe o jquery:
<scritp src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
O código utilizando o 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());
});
});
Resultado:
https://jsfiddle.net/wictor/uqs57ugL/1/