Advertisement
fakhrycodepolitan

Password validation

Oct 9th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.33 KB | Source Code | 0 0
  1. const password = prompt('buat password');
  2. let regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@.#$!%*?&])[A-Za-z\d@.#$!%*?&]{8,15}$/;
  3.  
  4. if (
  5.     password.length >= 6 &&
  6.     password.indexOf(' ') === -1 &&
  7.     regex.test(password)
  8. ) {
  9.     console.log('Password valid');
  10. } else {
  11.     console.log('Password tidak memenuhi syarat');
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement