I want the field to change to green, as it matches 4 letters followed by 4 numbers, like "blab1111".
This is the regex code: [A-Za-z]{4}+[0-9]{4}.
I tried also ^[A-Za-z]{4}+[0-9]{4}$.
I am using this code:
input:invalid {
background: hsla(0, 90%, 70%, 1);
}
input:valid {
background: hsla(100, 90%, 70%, 1);
}
<input type='text' required name='username' autocomplete="off" id='username' pattern="[A-Za-z]{4}+[0-9]{4}" maxlength="50" />
The field is not correctly switching to the :valid state.