I'm looking to give my form inputs a red border they are invalid when the form submits. Currently I have achieved this by using the input:invalid
selectors in CSS; however, this makes it so that the red borders appear from the start, even before the user types anything into the inputs fields. What I'm looking for is to not have any red borders until the form is submitted and only red borders for the invalid inputs that prevent the form from a successful submission. I am working with Vue.js on this and my code is below.
input,
textarea {
font-size: 14px;
padding: 7px;
filter: none;
&[type='email'],
&[type='password'],
&[type='text'],
&[type='search'] {
height: 20px;
font-family: inherit;
font-weight: bold;
border: 1.4px solid white;
border-radius: 3px;
background: #fff;
color: #002169;
transition: all 0.3s;
&:invalid {
border: 1.4px solid rgb(255, 18, 18);
}
&::placeholder {
color: #0378a6;
opacity: 1;
}
}
}