<html>
<head>
<meta charset="utf-8">
<title>Password Tutorial</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div class="container">
<div class="second-example">
<input type="password" id="password-2" onkeyup="validate();">
</div>
<div id="validation-txt">
</div>
</div>
</body>
</html>
html, body {
height: 100%;
background: #212121;
margin: 0px;
}
.first-example , .second-example, .third-example{
margin-bottom: 10px;
}
body {
align-items: center;
justify-content: center;
display: flex;
}
input {
width: 250px;
padding: 15px 12px;
font-size:22px;
}
.fa{
color:white;
font-size:27px;
margin-left:8px;
}
#validation-txt{
color:red;
font-size:18px;
width: 300px;
}
#password-3{
text-security: disc;
text-security:circle;
text-security:circle;
}
input[type=number]::inner-spin-button,
input[type=number]::outer-spin-button {
appearance: none;
margin: 0;
}
function validate(){
var validationField = document.getElementById('validation-txt');
var password= document.getElementById('password-2');
var content = password.value;
var errors = [];
console.log(content);
if (content.length < 8) {
errors.push("Your password must be at least 8 characters");
}
if (content.search(/[a-z]/i) < 0) {
errors.push("Your password must contain at least one letter.");
}
if (content.search(/[0-9]/i) < 0) {
errors.push("Your password must contain at least one digit.");
}
if (errors.length > 0) {
validationField.innerHTML = errors.join('');
return false;
}
validationField.innerHTML = errors.join('');
return true;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.