Salve a tutti.
Ho trovato questo script in rete (gratuito, per cui penso non ci siano problemi se posto il codice) che serve a misurare automaticamente l'efficacia di una password. L'ho installato nel modulo di registrazione del mio forum.
Potete vederlo qui Forum
Ora: pare funzionare perfettamente con explorer (provate per favore), mentre con firefox nessun segno di vita! Io non sono così esperto da comprendere il motivo di tale incompatibilità e spero nel vostro competente aiuto.
Lo script è attivato dall'evento onKeyPress="passwordChanged()"
Il codice:
codice:var ieDOM = false, nsDOM = false; var stdDOM = document.getElementById; function initMethod() { //Determine the browser support for the DOM if( !stdDOM ) { ieDOM = document.all; if( !ieDOM ) { nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4)); } } passwordChanged(); } function getObject(objectId) { if (stdDOM) return document.getElementById(objectId); if (ieDOM) return document.all[objectId]; if (nsDOM) return document.layers[objectId]; } function getObjectStyle(objectId) { if (nsDOM) return getObject(objectId); var obj = getObject(objectId); return obj.style; } function showDefault(objectId) { showCell(objectId, "#E2E2E2", "#E2E2E2"); } function showCell(objectId, foreColor, backColor) { getObjectStyle(objectId).color = foreColor; getObjectStyle(objectId).backgroundColor = backColor; } function showWeak() { showCell("pwWeak", "Black", "#FF6666"); showDefault("pwMedium"); showDefault("pwStrong"); } function showMedium() { showCell("pwWeak", "#FFCC66", "#FFCC66"); showCell("pwMedium", "Black", "#FFCC66"); showDefault("pwStrong"); } function showStrong() { showCell("pwWeak", "#80FF80", "#80FF80"); showCell("pwMedium", "#80FF80", "#80FF80"); showCell("pwStrong", "Black", "#80FF80"); } function showUndetermined() { showDefault("pwWeak"); showDefault("pwMedium"); showDefault("pwStrong"); } function passwordChanged() { var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); var enoughRegex = new RegExp("(?=.{3,}).*", "g"); var pwd = getObject("req_password1").value; if( false == enoughRegex.test(pwd) ) { showUndetermined(); } else if( strongRegex.test(pwd) ) { showStrong(); } else if( mediumRegex.test( pwd ) ) { showMedium(); } else { showWeak(); } }
Qualche idea in proposito?

Rispondi quotando