You are here: irt.org | FAQ | JavaScript | Number | Q1431 [ previous next ]
Try:
<form name="myform"> <input type="text" name="password"> </form> <script language="JavaScript"><!-- var choice = "1234567890abcdefghiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXTZ"; var size_of_password = 8; var password = ''; for (var i=0; i<size_of_password; i++) { var rnd = Math.floor(Math.random() * choice.length); password += choice.substring(rnd,rnd+1); } document.myform.password.value = password; //--></script>