Password Validator | Sololearn: Learn to code for FREE!

0

Password Validator

Why is the password validator not working. Whenever i type 1 it should change the color to limegreen https://code.sololearn.com/WzTa2OggAYJo/?ref=app

5/26/2022 4:42:23 PM

Your Mom

12 Answers

New Answer

+1

The if statement will run at the beginning, but there is no input value at that time. So you need to create a function and connect it via EventListener to check for changes in the input field. https://code.sololearn.com/W6XykbZaD68X/?ref=app

+1

Your Mom change the last part of your script: you used = instead of === in you if statement. function submit() { if (document.getElementById("number").style.color === "limegreen" && document.getElementById("symbol").style.color === "limegreen" && document.getElementById("lowerCase").style.color === "limegreen" && document.getElementById("upperCase").style.color === "limegreen" && document.getElementById("characters").style.color === "limegreen") { alert("Submitted Form!"); } }

+1

Okay, thanks one last part. Ive been wondering on this for a while how do you make 2 things on the same line? The only way I know is width: 100vw; but sometimes that doesnt work. I want my the names on the same line and my password on a different line with my checkbox and my submit on a different line after my password https://code.sololearn.com/WzTa2OggAYJo/?ref=app

+1

Ye sorry Bob_Li im a pretty lazy person haha. Its funny cus I have to wear glasses because I cant see very far and i cant read tiny letters but i can somehow read this

0

After submit is clicked or ?

0

0

whats the difference between onkeydown, onkeypress, onkeyup and the others. i looked on w3schools but all it says is it does something when you press a key on your keyboard

0

Tsering

0

0

Okay why is my color and stuff not working anymore? https://code.sololearn.com/WzTa2OggAYJo/?ref=app

0

Your Mom put the inputs inside a flex div. Adjust the length of the input boxes by adding a size attribute=number of characters. <div style="display:flex;"> <input type="text" id="yourName" placeholder="First Name" size="15"></input> <input type="text" id="yourName" placeholder="Last Name" size="15"></input> </div>

0

Your Mom you should assign your dom elements to const variables. That way, it would be easier to use them later in your code(getting or assigning values, changing style or adding callback functions). Wouldn't want to type and read document.getElementById(...) all the time. It's error prone and hard to read.