rwobben
September 27, 2022, 6:06am
#1
Tell us what’s happening:
Right now I see the validation error all the time.
Describe your issue in detail here.
What I try to do is to use aria-live to show or hide a validation error
Your code so far
this is not a challenge from FCC but from a site called front end mentors
ilenia
September 27, 2022, 9:42am
#2
do you have a live version of this so we can see the issue?
rwobben
September 27, 2022, 9:55am
#3
ilenia
September 27, 2022, 10:11am
#4
You have lots of code, can you create a sample with the minimum amount of code needed to reproduce the issue?
rwobben
September 27, 2022, 10:21am
#5
it is good it will be a fsfiddle or something ?
ilenia
September 27, 2022, 10:22am
#6
that’s a perfectly valid tool to use
rwobben
September 27, 2022, 10:30am
#7
here it is Edit fiddle - JSFiddle - Code Playground
What is want is that someone enters for example a character the error message is shown.
But on some way I cannot invoke the validation it seems
ilenia
September 27, 2022, 11:37am
#8
Something like this. But your pattern makes this always invalid so
You may want to look up how to use the pattern
attribute
For example it doesn’t want the /
at the beginning and end
nor you need ^
and $
let money = document.querySelector('#amount');
let divHint = document.querySelector('#usernameHint')
money.addEventListener('input', (e) =>{
let checked = money.checkValidity();
console.log(checked);
if (!checked) {
divHint.classList.remove('hidden')
} else {
divHint.classList.add('hidden')
}
});
rwobben
September 27, 2022, 11:41am
#9
Nope. when I try it , i do not see the error message
ilenia
September 27, 2022, 11:43am
#10
that code works on my side. Change the code in the jsfiddle, let’s see
rwobben
September 27, 2022, 11:59am
#11
you are right.
Have to figure out why it will not work locally
Thanks for the help