Latest solutions
Latest comments
- @jameslegoff92@JamesTheLessFC
Hi @jameslegoff92, Nice job on this! To change the styles of your input element when there is an error present (without using inline styles), you could create a class for inputs with errors and apply the class when an error is found. Something like this:
//stylesheet input.errors { outline-color: red; } //validator function document.getElementById("email_input").classList.add("errors");
- @purushotham91@JamesTheLessFC
Hi @purushotham91, Nice job on this! I remember wondering the same thing. I've found that naming classes does get easier with time (I don't spend more than a few seconds thinking about it now.) However there are a few things I do keep in mind. When a project is especially complex and you come back to it after a break, you'll thank yourself for giving your classes names that make sense and are easy to tell what they are. For instance if it's a div element functioning as a wrapper/container, include that in the name (i.e. "gallery_container"). It's also a good idea to be consistent with your naming, like sticking to camelCase or using underscores to separate words. Or if you're giving class names to your buttons, you could do something like "submit_button" and "delete_button", etc. Naming these "button_1" and "button_2" will be confusing once you have a lot of classes in your project. Above all, it should be easy for someone reading your code to figure out what the class name refers to.
Marked as helpful