/*-------------------------------------------------------------------------------------------------
PASSWORD
-------------------------------------------------------------------------------------------------*/
var pwd1 = document.getElementById("pwd1");
var pwd2 = document.getElementById("pwd2");
pwd1.addEventListener("keyup", function(){
// pwd1 must have at least 8 characters
if (pwd1.value.length < 8) {
pwd1Hint.setAttribute('class', 'red');
pwd1Hint.innerHTML = "Your password must be at least 8 characters.";
}
// success
if (pwd1.value.length >= 8) {
//pwd1Hint.setAttribute('class', 'pass');
pwd1Hint.innerHTML = "";
}
});
pwd2.addEventListener("keyup", function(){
// compare the values in the password fields
if(pwd1.value != pwd2.value){
//The passwords do not match
pwd2Hint.setAttribute('class', 'red');
pwd2Hint.innerHTML = "Your passwords must match";
} else {
//The passwords match
//pwd2Hint.setAttribute('class', 'pass');
pwd2Hint.innerHTML = "";
}
});
/*-------------------------------------------------------------------------------------------------
Counting Bio Characters: enter max of 140 and stop
-------------------------------------------------------------------------------------------------*/
var maxChars = 140;
var bioInput = document.getElementById("bio");
var c = document.getElementById("charsLeft");
c.innerHTML = maxChars;
// All we need is events, the length property, and writing
// to the DOM to make a counter
bioInput.addEventListener("keydown", charsLeft);
function charsLeft(e) {
var len = bioInput.value.length;
//console.log(len);
if (len >= maxChars) {
console.log(maxChars);
e.preventDefault();
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.