v1
12/8/2022 by hkotsubo -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
let regex = /^(?=.*[@!#$%^&*()/\\])(?=.*[0-9])(?=.*[A-Za-z])[@!#$%^&*()/\\a-zA-Z0-9]{8,20}$/;

function validar(string, especiais){
    // primeiro valida o tamanho
    if (string.length < 8 || string.length > 20){
        return false;
    }
    let especial = 0, letra = 0, numero = 0;
    for (let i = 0; i < string.length; i++) {
        const char = string[i];
        if ( ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') ) {
            letra++;
        } else if ('0' <= char && char <= '9') {
            numero++;
        } else if (especiais.has(char)) {
            especial++;
        } else {
            // não pode ter outro tipo de caractere
            return false;
        }
    }
    return especial > 0 && letra > 0 && numero > 0;
}
const especiais = new Set(['@', '!', '#', '$', '%', '^', '&', '*', '(', ')', '/', '\\']);

delete caserun single casemove downdrag and drop case


ready



regex.test('a@4DFFd$fd')
delete caserun single casemove updrag and drop case


ready



validar('a@4DFFd$fd', especiais)
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN