Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css"
      integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A=="
      crossorigin="anonymous"
      referrerpolicy="no-referrer"
    />
    <title>Validasi Password</title>
  </head>
  <body>
    <div class="box">
      <div class="inputBox">
        <input
          type="password"
          id="pswrd"
          placeholder="Password"
          onkeyup="checkPassword(this.value)"
        />
        <span id="toggleBtn"></span>
      </div>
      <div class="validation">
        <ul>
          <li id="lower">At least one lowercase character</li>
          <li id="upper">At least one uppercase character</li>
          <li id="digit">At least one number</li>
          <li id="special">At least one special character</li>
          <li id="length">At least 8 characters</li>
        </ul>
      </div>
    </div>
    <script src="script.js"></script>
  </body>
</html>

              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Poppins&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: rgb(54, 243, 101);
}

.box {
  position: relative;
  width: 300px;
}

.box .inputBox {
  position: relative;
  width: 100%;
  background: #fff;
  padding: 5px;
  border-radius: 8px;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.15);
}

.box .inputBox input {
  position: relative;
  width: 100%;
  outline: none;
  border: none;
  padding: 10px 5px;
}

/* icon mata */

.box .inputBox #toggleBtn {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.box .inputBox #toggleBtn::before {
  content: "\f06e";
  font-family: fontAwesome;
}

/* hide eye */

.box .inputBox #toggleBtn.hide::before {
  content: "\f070";
}

.validation {
  background-color: rgb(40, 155, 40);
  padding: 10px;
  margin-top: 30px;
  border-radius: 8px;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.15);
}

.validation ul {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.validation ul li {
  position: relative;
  list-style: none;
  color: #fff;
  font-size: 0.85em;
  transition: 0.5s;
}

.validation ul li.valid {
  color: rgba(255, 255, 255, 0.5);
}

.validation ul li::before {
  content: "\f192";
  width: 20px;
  height: 10px;
  font-family: fontAwesome;
  display: inline-flex;
}

.validation ul li.valid::before {
  content: "\f00c";
  color: blanchedalmond;
}

              
            
!

JS

              
                let pswrd = document.getElementById("pswrd");
let toggleBtn = document.getElementById("toggleBtn");

let lowerCase = document.getElementById("lower");
let upperCase = document.getElementById("upper");
let digit = document.getElementById("digit");
let specialChar = document.getElementById("special");
let minLength = document.getElementById("length");

function checkPassword(data) {
  // javascript regular expression pattern
  const lower = new RegExp("(?=.*[a-z])");
  const upper = new RegExp("(?=.*[A-Z])");
  const number = new RegExp("(?=.*[0-9])");
  const special = new RegExp("(?=.*[!@#$%^&*])");
  const length = new RegExp("(?=.{8,})");

  // lower case validation check
  if (lower.test(data)) {
    lowerCase.classList.add("valid");
  } else {
    lowerCase.classList.remove("valid");
  }

  // upper case validation check
  if (upper.test(data)) {
    upperCase.classList.add("valid");
  } else {
    upperCase.classList.remove("valid");
  }

  // number case validation check
  if (number.test(data)) {
    digit.classList.add("valid");
  } else {
    digit.classList.remove("valid");
  }

  // special character case validation check
  if (special.test(data)) {
    specialChar.classList.add("valid");
  } else {
    specialChar.classList.remove("valid");
  }

  // minimal length case validation check
  if (length.test(data)) {
    minLength.classList.add("valid");
  } else {
    minLength.classList.remove("valid");
  }
}

// show hide password
toggleBtn.onclick = function () {
  if (pswrd.type === "password") {
    pswrd.setAttribute("type", "text");
    toggleBtn.classList.add("hide");
  } else {
    pswrd.setAttribute("type", "password");
    toggleBtn.classList.remove("hide");
  }
};

              
            
!
999px

Console