Currently, I am in the process of developing a form for a website using HTML, CSS, and Angular JS. Although I have successfully achieved my desired outcome, I can't help but think that there might be a more efficient way to approach it. With that in mind, I wanted to inquire if there are alternative methods to obtain the same result.
The core of my method involves using AngularJS form validation within the form. When the form is deemed valid, it adds the ng-valid
class to the form element. To visually represent this status, I've incorporated a background image - a red X for invalid forms, and a green tick for valid ones. Since the addition of the ng-valid
class serves as an indicator of validity, I have outlined the following CSS to adjust the displayed image:
.ng-valid>div>div>div>div>a>div>div.regImg1{
background-image: url('../img/green-tick.png');
}
My standard CSS rule for this purpose is:
.regImg1{
background-image: url('../img/grey-tick.png');
}
Although this setup functions correctly, I'm mindful that any alterations to the HTML structure could potentially disrupt it. Therefore, I am curious if there exists a more elegant solution that remains resilient to HTML modifications.