Is there a way to translate the following CSS code into JavaScript? Basically, I want it to apply the style rules after the onchange event.
.appnitro input:required:valid, .appnitro textarea:required:valid {
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
.appnitro input:focus:invalid, .appnitro textarea:focus:invalid {
box-shadow: 0 0 5px #5d45252;
border-color: #b03535;
}
<script>
function myFunction(){
// Code goes here
}
</script>
<form id="form_664184" class="appnitro" method="post" action="">
<input type="text" id="element_3" name="element_2_1" value="Title" onchange="myFunction()" required />
</form>