Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

password validation in javascript

// Commonly used regular expression

// Check 2-9 characters, false if not matched, true if matched
const validateName = (name) => {
   const reg = /^[u4e00-u9fa5]{2,9}$/;
   return reg.test(name);
};
// Verify phone number
const validatePhoneNum = (mobile) => {
   const reg = /^1[3,4,5,6,7,8,9]d{9}$/;
   return reg.test(mobile);
};
// Check passwords consisting of 0 to 8
//uppercase and lowercase 
//alphanumeric underscores
const validatePassword = (password) => {
   const reg = /^[a-zA-Z0-9_]{0,9}$/;
   return reg.test(password);
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #password #validation #javascript
ADD COMMENT
Topic
Name
1+1 =