How can I use this random password code, and then insert the password into email which is sent to the user after the registration has been finished?
thx
[HTML]<html>
<head>
<title>javascript: Password Generator</title>
<style type="text/css">
input, select { font-family: Verdana, Arial, sans-serif;
font-size: 16pt;
font-weight: bold;
}
</style>
<script language="JavaScript">
function GeneratePassword() {
if (parseInt(navigator.appVersion) <= 3) {
alert("Sorry this only works in 4.0+ browsers");
return true;
}
var length=8;
var sPassword = "";
length = document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;
var noPunction = (document.aForm.punc.checked);
var randomLength = (document.aForm.rLen.checked);
if (randomLength) {
length = Math.random();
length = parseInt(length * 100);
length = (length % 7) + 6
}
for (i=0; i < length; i++) {
numI = getRandomNum();
if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }
sPassword = sPassword + String.fromCharCode(numI);
}
document.aForm.passField.value = sPassword
return true;
}
function getRandomNum() {
// between 0 - 1
var rndNum = Math.random()
// rndNum from 0 - 1000
rndNum = parseInt(rndNum * 1000);
// rndNum from 33 - 127
rndNum = (rndNum % 94) + 33;
return rndNum;
}
function checkPunc(num) {
if ((num >=33) && (num <=47)) { return true; }
if ((num >=58) && (num <=64)) { return true; }
if ((num >=91) && (num <=96)) { return true; }
if ((num >=123) && (num <=126)) { return true; }
return false;
}
</script>
<h2>javascript: Password Generator</h2>
<p><form name="aForm">
<table>
<tr>
<td>Generated Password:<br />
<input type="text" name="passField" value="" size="15"><br /></td>
<td># of chars<br />
<select name="charLen">
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8" selected>8
<option value="9">9
<option value="10">10
<option value="11">11
<option value="12">12
<option value="13">13
<option value="14">14
<option value="15">15
</select>
</td>
</tr>
<tr>
<td><p><input type="checkbox" name="punc" checked> No Punction Marks <br />
<input type="checkbox" name="rLen"> Random Length (6 - 12) <br /></p></td>
<td> </td>
</tr>
<tr><td colspan="2" align="center"> </td></tr>
<tr><td colspan="2" align="center">
<p><input type="button" value=" Generate Password " onClick="GeneratePassword()"></p></td>
</tr>
</table>[/HTML]