0

I'm trying to reveal an error message by setting the opacity back to 1 when the error occurs, but I'm having trouble applying styling to the ::after psuedo-element using JS. Also, whenever I click on the form submit button, nothing occurs, even if the passwords match, as I don't know how to resume it after using e.preventDefault(). How can I complete the password-validation checker?

Here is a link to the html and main css file on JSFiddle, if that is necessary to solve the problem.

const form = document.getElementById("main-form");
const password1 = document.getElementById("pass");
const password2 = document.getElementById("conf-pass");
const passLabel1 = document.querySelector(".passLabel1");
const passLabel2 = document.querySelector(".passLabel2");
const passLabel1After = window.getComputedStyle(passLabel1, "::after");
const passLabel2After = window.getComputedStyle(passLabel2, "::after");



form.addEventListener("submit", (e)=> {
    e.preventDefault();
    checkPasswords();
});

function checkPasswords (){
    const pass1Value = password1.value.trim();
    const pass2Value = password2.value.trim();

    if (pass1Value !== pass2Value) {
        passLabel1After.setProperty("opacity", 1);
        passLabel2After.setProperty("opacity", 1);
    } else {

    }
}
Messiah
  • 1
  • 1
  • Does this answer your question? [Change the style of :before and :after pseudo-elements?](https://stackoverflow.com/questions/21032481/change-the-style-of-before-and-after-pseudo-elements) – Alexis Nov 11 '22 at 07:36

0 Answers0