値が空の場合、InputとTextareaが赤で表示されるようにしたいのですが、それは入力用に機能しますが、textarea用には機能しません。助けてもらえますか?Textareaの色、bordercolorは変更されません
$(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>
、 –
あまり問題ありません、ありがとうございません、それが働いていますか? –
部分的に、私は尋ねたものを得ましたが、Text.value === " "#f00": "#0f0";空でないときは緑色に戻り、.CSSではこれを達成できませんでした –