Validate string (read description)

// ************************* English version ************************* // n = numbers, uc = uppercase, lc = lowercase, s = special public bool Validate() { string n = "0123456789"; string uc = "ABCDEFGHIJKMNLÑOPQRSTUVWXYZ"; string lc = uc.ToLower(); string s = "!#$%&'()*+,-./:;<=>?@[]^_`{|}~"; bool hasn = false; bool haslc = false; bool hasuc = false; bool hass = false; for (int i = 0; i < Pass.Length && !hasn; i++) { for (int j = 0; j < n.Length; j++) { if (n[j] == Pass[i]) { hasn = true; } } } for (int i = 0; i < Pass.Length && !hasuc; i++) { for (int j = 0; j < uc.Length; j++) { if (uc[j] == Pass[i]) { hasuc = true; } } } for (int i = 0; i < Pass.Length && !haslc; i++) { for (int j = 0; j < lc.Length; j++) { if (lc[j] == Pass[i]) { haslc = true; } } } for (int i = 0; i < Pass.Length && !hass; i++) { for (int j = 0; j < s.Length; j++) { if (s[j] == Pass[i]) { hass = true; } } } return Pass.Length >= 8 && Descrpcion.Length <= 250 && hasn && haslc && hasuc && hass; } //************************* version en Español ************************* public bool Validar() { string numeros = "0123456789"; string mayuscula = "ABCDEFGHIJKMNLÑOPQRSTUVWXYZ"; string minuscula = mayuscula.ToLower(); string especial = "!#$%&'()*+,-./:;<=>?@[]^_`{|}~"; bool tieneNumero = false; bool tieneMinuscula = false; bool tieneMayuscula = false; bool tieneEspecial = false; for (int i = 0; i < Contrasenia.Length && !tieneNumero; i++) { for (int j = 0; j < numeros.Length; j++) { if (numeros[j] == Contrasenia[i]) { tieneNumero = true; } } } for (int i = 0; i < Contrasenia.Length && !tieneMayuscula; i++) { for (int j = 0; j < mayuscula.Length; j++) { if (mayuscula[j] == Contrasenia[i]) { tieneMayuscula = true; } } } for (int i = 0; i < Contrasenia.Length && !tieneMinuscula; i++) { for (int j = 0; j < minuscula.Length; j++) { if (minuscula[j] == Contrasenia[i]) { tieneMinuscula = true; } } } for (int i = 0; i < Contrasenia.Length && !tieneEspecial; i++) { for (int j = 0; j < especial.Length; j++) { if (especial[j] == Contrasenia[i]) { tieneEspecial = true; } } } return Contrasenia.Length >= 8 && Descrpcion.Length <= 250 && tieneNumero && tieneMinuscula && tieneMayuscula && tieneEspecial; }
Method to validate a string ( password for example)
Validations :
- If has capital letters.
- If has lowercase letters
- If has numbers.
- If has special characters.
///////////////////////// spanish ////////////////////////////////////
Metodo para validar un string, puede ser una contraseña.
Validaciones:
- Si tiene mayusculas.
- Si tiene minusculas
- Si tiene numeros.
-Si tiene caracteres especiales.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.