Hi, I have pre-written code that produces a license key but I don’t like the format that the key is in and was wondering if I could get some help fixing it?
This is the code
@section('scripts')
<script type="text/javascript">
function Createkey(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
$('#licenses-gen').click(function(){
var GetType = $('#type_of_key_id').find(":selected").text();
$('#licence').val(GetType.trim()+Createkey(18));
});
</script>
@endsection
the output is just a random string of 18 characters like: H3CJPE5JMS501FH52A
though I want to get an output like: FSOWP-DHJEO-SKJ3D-2DF5R-3FG51
What can I change in the code to get the second output option?