<form name="pgenerate"><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));
temp+=keylist2.charAt(Math.floor(Math.random()*keylist2.length));
temp+=keylist3.charAt(Math.floor(Math.random()*keylist3.length));
temp+=keylist4.charAt(Math.floor(Math.random()*keylist4.length));
}
return temp;
}
function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength);
}
</script>