I have bootstrap modal, and i want add red border to textarea when notes is empty..
Modal :
div class="modal fade" id="modal_reject" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="form-group has-error">
<label class="col-sm-2 control-label"> Add Note <b style="color:red;">*</b></label>
<div style="margin-left: 5%;margin-right: 5%;">
<textarea id="NOTES_REJECT_SV" name="NOTES" class="form-control" required style="height: 100px;"></textarea>
</div>
</div>
<div class="modal-footer ">
<button type="button" id="submit" form="form" style="width:150px;height:40px;text-align:center;" class="btn btn-ok pull-right" ">Reject</button>
<button type="button" class="btn btn-light pull-right" style="width:120px;height:40px;" data-dismiss="modal" >CANCEL</button>
</div>
</div>
</div>
and my Javascript :
$('#modal_reject').on('click', '#submit', function(event) {
event.preventDefault();
var notes = $("#NOTES_REJECT_SV").val();
// alert(NOTES);
console.log('notes',notes)
if(notes){
$('#NOTES_REJECT_SV').css('border-color', 'red'); // < not working
$('#modal_reject').modal('hide')
return false;
}
.css('border', '1px solid red')
? – techie_28