- Timestamp:
- May 20, 2015, 1:10:42 PM (9 years ago)
- Branches:
- master
- Children:
- 878d01d
- Parents:
- 9cccf8d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
static/js/funciones.js
rc4b04e5 r5b67958 48 48 return !!/^([A-Za-z\s\b])$/.test(keychar); 49 49 } 50 51 /** 52 * @brief Función que valida la fortaleza de la contraseña del usuario 53 * 54 * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) 55 * @copyright GNU/GPLv2 56 * @date 20-05-2015 57 * @param password Variable de tipo string que contiene los caracteres de la contraseña especificada en el formulario 58 */ 59 function passwordStrength(password) { 60 var desc = new Array(); 61 desc[0] = "Muy Débil"; 62 desc[1] = "Débil"; 63 desc[2] = "Mejor"; 64 desc[3] = "Buena"; 65 desc[4] = "Fuerte"; 66 desc[5] = "Muy Fuerte"; 67 68 var score = 0; 69 70 //if password bigger than 6 give 1 point 71 if (password.length > 6) score++; 72 73 //if password has both lower and uppercase characters give 1 point 74 if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++; 75 76 //if password has at least one number give 1 point 77 if (password.match(/\d+/)) score++; 78 79 //if password has at least one special caracther give 1 point 80 if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++; 81 82 //if password bigger than 12 give another 1 point 83 if (password.length > 12) score++; 84 85 document.getElementById("passwordDescription").innerHTML = desc[score]; 86 document.getElementById("passwordStrength").className = "strength" + score; 87 }
Note: See TracChangeset
for help on using the changeset viewer.