validation

 email validation:

function validateEmail(email) {
    const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(String(email).toLowerCase());
}
https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a
https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a
https://www.youtube.com/watch?v=wiQSUdJsc-I
https://en.wikipedia.org/wiki/Regular_expression

Regular Expression.
A password is considered valid if all the following constraints are satisfied:

  • It contains at least 8 characters and at most 20 characters.
  • It contains at least one digit.
  • It contains at least one upper case alphabet.
  • It contains at least one lower case alphabet.
  • It contains at least one special character which includes !@#$%&*()-+=^.
  • It doesn’t contain any white space.

regex = “^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&-+=()])(?=\\S+$).{8, 20}$”

where:

  • ^ represents starting character of the string.
  • (?=.*[0-9]) represents a digit must occur at least once.
  • (?=.*[a-z]) represents a lower case alphabet must occur at least once.
  • (?=.*[A-Z]) represents an upper case alphabet that must occur at least once.
  • (?=.*[@#$%^&-+=()] represents a special character that must occur at least once.
  • (?=\\S+$) white spaces don’t allowed in the entire string.
  • .{8, 20} represents at least 8 characters and at most 20 characters.
  • $ represents the end of the string.

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation