<form name="pgenerate">متوسط <input type="checkbox" id="check1">
حرفه ای <input type="checkbox" id="check2">
فوق حرفه ای <input type="checkbox" id="check3">
<button type="button" value="generatepassword" onClick="history.go();populateform(this.form.thelength.value)">ساخت پسورد</button><br><br>
<input type="text" size="25" name="output" class="passwd"><br><br>
<b>انتخاب کنید پسورد چند رقمی باشد</b>
<input type="text" name="thelength" size="3" value="4" maxlength="2">
</form>
<script>
var keylist1='1234567890',
keylist2='ABCDEFGHIJKLMNOPQRSTUVWXYZ',
keylist3='abcdefghijklmnopqrstuvwxyz',
keylist4='!\%&()*+,-./:;<=>?@[\]^_`{|.o}~‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–˜™š›œžŸ¡¢£¤¥¦§¨©ª,«¬®¯°±´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ€~‰‡™•‘!$%Qº¸³©ª²¦ª¨£½¹º®°¢«µ-/‰€™';
temp='';
function generatepass(plength){
temp='';
for(i=0;i<plength;i++){
temp+=keylist1.charAt(Math.floor(Math.random()*keylist1.length));
if(document.getElementById('check1').checked)
temp+=keylist1.charAt(Math.floor(Math.random()*keylist1.length))+keylist2.charAt(Math.floor(Math.random()*keylist2.length));
if(document.getElementById('check2').checked)
temp+=keylist1.charAt(Math.floor(Math.random()*keylist1.length))+keylist2.charAt(Math.floor(Math.random()*keylist2.length))+keylist3.charAt(Math.floor(Math.random()*keylist3.length));
if(document.getElementById('check3').checked)
temp+=keylist1.charAt(Math.floor(Math.random()*keylist1.length))+keylist2.charAt(Math.floor(Math.random()*keylist2.length))+keylist3.charAt(Math.floor(Math.random()*keylist3.length))+keylist4.charAt(Math.floor(Math.random()*keylist4.length));
}
return temp;
}
function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength);
}
</script>