erik8
erik8 - Ominide - 45 Punti
Rispondi Cita Salva

Html
Ciao a tutti,
Ho cercati di scrivere una pagina in html per un generatore di password ma non mi funziona. Mi potreste aiutare a trovare l'errore?
Grazie mille.

Qui sotto ciò che ho scritto:
<html>
<head>

<script language="JavaScript" type="text/javascript">

function verifyInput()
{
if (!document.forms[0].elements[3].checked && !document.forms[0].elements[4].checked && !document.forms[0].elements[5].checked)
{
alert('You need to choose the type of characters you want in your password');
return 0;
}
if(document.forms[0].elements[6].value=="";)
{
alert('You must enter the desired length for your password');
return 0;
}
}

function getRandomNum(lbound, ubound)
{
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar(number, alpha, other, extra)
{
var numberChars = "0123456789";
var alphaChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var binaryChars = "ò™ªŠÇæìûó‰‡Ø¥×äƒ?ûœ%Ãʧ¶™Ï‡ôփ߹݀̕ÛÒ„«ýëŒôÈ•£ªêùÏÉÆé#ՔЯײ¡¾";
var moreBinChars = "š€™±&†®Ôæ«Ÿ“õÁÒèÂÀ‡ÑØÚæà ßû‰›€ïÜÛþ¾å“DZÄÖ÷ÕŒ%þŠšÆ©¢ÐÞ¬ôŽžÀ©Ó°©·ß°";
var otherChars = binaryChars+moreBinChars;
var charSet = extra;

if (number == true) charSet += numberChars;
if (alpha == true) charSet += alphaChars;
if (other == true) charSet += otherChars;

return charSet.charAt(getRandomNum(0, charSet.length));
}

function getPassword(length, extraChars, firstNumber, firstAlpha, firstOther, latterNumber, latterAlpha, latterOther)
{
var pass = "";
length++;

if (length > 0) pass = pass + getRandomChar(firstNumber, firstAlpha, firstOther, extraChars);

for (var idx = 1; idx < length; ++idx)
{
pass = pass + getRandomChar(latterNumber, latterAlpha, latterOther, extraChars);
}
return pass;
}
</script>

</head>
<body>

<table border=1 style="border-color:black" bgcolor="#e0e0e0" align=center>
<tr>
<td>

<form name="myform">
<input type=hidden name=firstNumber><input type=hidden name=firstAlpha><input type=hidden name=firstOther>

<p style="font:bold 8pt arial;">Password characters:
<input type=checkbox name=latterNumber>Numbers
<input type=checkbox name=latterAlpha>Letters
<input type=checkbox name=latterOther>Symbols

<p style="font:bold 8pt arial">Password length:
<input type=text name=passwordLength size=3 value=""> (Should be at least 8 characters)

<p style="font:bold 8pt arial">Extra characters:
<input type=text name=extraChars size=3> (This feature is NOT necessary)

<p style="font:bold 8pt arial;">Your generated password:
<input type=text name=password size=25>

<center>
<br>
<br>
<input type=button value="Create Password" style="cursor:hand" onClick="verifyInput(); document.myform.password.value =
getPassword(document.myform.passwordLength.value, document.myform.extraChars.value,
document.myform.firstNumber.checked, document.myform.firstAlpha.checked, document.myform.firstOther.checked,
document.myform.latterNumber.checked, document.myform.latterAlpha.checked, document.myform.latterOther.checked);">
</center>
</form>

</td></tr></table>

</body>
</html>

Come guadagno Punti nel Forum? Leggi la guida completa
In evidenza
Classifica Mensile
Vincitori di agosto
Vincitori di agosto

Come partecipare? | Classifica Community

Community Live

Partecipa alla Community e scala la classifica

Vai al Forum | Invia appunti | Vai alla classifica

Registrati via email