qString: Generate Password
Generates a 12-character password. Randomly extracts 2 characters from “23456789”, 4 characters from “ACFGHJKNRSUXYZ”, 4 characters from “acfghjknrsuxyz”, and 2 characters from “#$%&+-“. Characters that are easily misidentified (e.g., “1” and “l”) are not extracted.
Input / Output
→ qString (STRING_TEXTFIELD) q_NewPassword
Code Example
HTML/JavaScript (click to close)
<button type="button"
onclick="user_overwriteRandomPasswordToQstr (
'q_NewPassword'
)"> Generate Password </button>
※ Click to Overwrite / クリックで上書き
<script>
function user_overwriteRandomPasswordToQstr ( qStrFieldName ) {
const strNumeric = "23456789"; const numNumeric = 2;
const strUpper = "ACFGHJKNRSUXYZ"; const numUpper = 4;
const strLower = "acfghjknrsuxyz"; const numLower = 4;
const strSymbol = "#$%&+-"; const numSymbol = 2;
let strPwd = "";
for( let i = 0; i < numNumeric; i++ ){
strPwd += strNumeric.charAt( Math.floor( Math.random() * strNumeric.length ) );
}
for( let i = 0; i < numUpper; i++ ){
strPwd += strUpper.charAt( Math.floor( Math.random() * strUpper.length ) );
}
for( let i = 0; i < numLower; i++ ){
strPwd += strLower.charAt( Math.floor( Math.random() * strLower.length ) );
}
for( let i = 0; i < numSymbol; i++ ){
strPwd += strSymbol.charAt( Math.floor( Math.random() * strSymbol.length ) );
}
let arrPwd = strPwd.split("");
let j = arrPwd.length;
while ( j > 1 ) { // shuffle (Fisher-Yates)
let k = Math.floor( Math.random() * j );
j = j - 1;
if (j === k) continue;
let charTmp = arrPwd[j];
arrPwd[j] = arrPwd[k];
arrPwd[k] = charTmp;
}
qbpms.form.set( qStrFieldName, arrPwd.join("") ); // update the input form of Questetra
}
</script>
Freely modifiable HTML/JavaScript code, MIT License. No warranty of any kind.
Capture

