In my React component, I have a form with multiple input fields. In the CSS classes that I'm working with, there's an "invalid" pseudo-class that should highlight the field if its value is invalid. Currently, the input fields do not have any classes defined in my component. They're using the default styling that comes from the CSS file.
class MyForm extends Component {
render() {
return(
// There's more code here. Not showing to keep things simple
<input type="text" name="someProperty" value={myObject.someProperty} onChange={e => this.someFunction(e)} />
);
}
}
How do I actually use this -- meaning, how do I set the input field to invalid? I tried simply adding "invalid" to its CSS class but it didn't work.
This is what I tried with no results:
<input type="text" name="someProperty" className={showInvalid} value={myObject.someProperty} onChange={e => this.someFunction(e)} />
UPDATE:
Doing a bit more research on pseudo-classes, they do NOT go into the class. So in HTML, the input field would simply appear as below:
<input name"someProperty" invalid />