I am trying to figure out, using Javascript, how to generate a RANDOM 11 character string which requires a specific sequence of letters/numbers, in regards to position.
-----------------------------------------------------------------------
Example of what I need to be able to generate:
Key:
C - Constant (regardless of whether Alpha or Numeric Char; is NEVER randomized)
L - Alpha Character
N - Numeric Character
L/N - Either Letter or Number acceptable
|#1.|#2.|#3.|#4.|#5.|#6.|#7.|#8.|#9.|#10|#11|
|C..|C..|C..|L/N|L/N|N..|N...|N..|N...|N...|N...|
generated string example:
ABC1A123456
ABCAB859328
ABC41932013
ABCD2615982
ABCEF081799
ABC32701174
etc...
-----------------------------------------------------------------------
This is what I've started with.. I have my first 3 characters (the constants) and I have the alphanumeric characters that i want eligible for the randomization of the remaining 8 char of the sequence. But what I don't have, and what I'm asking the community to help me with, is how to implement rules so that my script will only allow the randomized generated strings to follow the description I've given above.
I hope I've explained everything clearly. =\
function makeid() {
var text = "ABC";
var possible = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (var i = 0; i < 8; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
Aucun commentaire:
Enregistrer un commentaire