I wanted the Input and Textarea to turn red through javascript when the values are empty, it worked for the input but not for the textarea. Can someone help?
$(document).on("click", '.btn-info.mailContact', function () {
values = {
Onderwerp: $('.Subject').val(),
Text: $('.TheMessage').value,
};
if ($('.Subject').val() != "" && $('.TheMessage').val() != "") {
State.sendContactMail(values);
window.location.href = '/confirmation';
} else {
Onderwerp.style.color = Onderwerp.value === "" ? "#f00" : "#0f0";
Onderwerp.style.borderColor = Onderwerp.value === "" ? "#f00" : "#0f0";
Text.style.color = Text.value === "" ? "#f00" : "#0f0";
Text.style.borderColor = Text.value === "" ? "#f00" : "#0f0";
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="form-control Subject" id="Onderwerp" placeholder="Vul je onderwerp hier in"/>
<textarea class="form-control TheMessage" id="Text" wrap="soft" placeholder="Vul je bericht hier in"></textarea>
<a id="btn-mailContact" class="btn btn-info mailContact">Verstuur contactformulier</a>