-2

Possible Duplicate:
How to create a GUID / UUID in Javascript?

I need to have a script that generates random numbers and letters with a form that looks like this:

M3KRT-CKKYV-YH4G4-YXP42-46FMT

Prefer jQuery, or javascript. I know how to generate number when the button is click using the .click() method in jQuery. But I can not find out how to actually make the code :(

Community
  • 1
  • 1
omnix
  • 1,819
  • 7
  • 23
  • 34

4 Answers4

4

Like this: Create GUID / UUID in JavaScript?

Community
  • 1
  • 1
BoltBait
  • 11,262
  • 9
  • 58
  • 86
2

Why do you include Win7 license key in your question?

Dmitry Gladkov
  • 1,307
  • 1
  • 12
  • 23
1

Modified this example a little:

Create GUID / UUID in JavaScript?

And came up with this:

function S5() {
    return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
}
function guid() {
    return (S5() + "-" + S5() + "-" + S5() + "-" + S5() + "-" + S5()).toUpperCase();
}
Community
  • 1
  • 1
fehays
  • 3,127
  • 1
  • 22
  • 43
0

Try this out...

function createGuid () {
  for (var i=5, out=[]; i--;) {
    out.push((Math.random()*58786559+1679615|0).toString(36));
  }
  return out.join('-').toUpperCase();
}

alert(createGuid());
Dagg Nabbit
  • 72,560
  • 18
  • 107
  • 141