I'm trying to validate a password and if it is ok, it will keep in an array regular expression only once. When I run the script in the mozilla browser, I get the following error: 'seguridadPass [i]. Test is not a function'. I would also like to know how I can do to delete the array 'comprobaciones', those regex that have not been used. Thank you for your help.
JAVSCRIPT
var compMay = /[A-ZÑ]/;
var compMin = /[a-zñ]/;
var compNum = /(?=.*\d)/;
var compCarEsp = /[!@#$%^&*(){}[\]<>¿¡?/|.:;_-]/;
var seguridadPass = [];
seguridadPass.push(compMin,compMay,compNum,compCarEsp);
comprobaciones = [];
$('#write').keyup(function(){
var pass = $(this).val();
if(pass!=''){
for(i=0;i<seguridadPass.length;i++){
if(seguridadPass[i].test(pass)){
//alert(seguridadPass[i]);
for(j=0;j<comprobaciones.length;j++){
if(comprobaciones[j]!=seguridadPass[i]){
comprobaciones.push(seguridadPass[i]);
}
}
}
}
}
else{
comprobaciones.splice(0,comprobaciones.length);
//comprobaciones = [];
}
});