I have an HTML <select>
tag and I want to make it dynamically required. I tried with jQuery but nothing happens.
This is the <select>
<select class="form-control" type="text" id="status">
<option value="" selected disabled>----- * ----</option>
<option value="1" >inactive</option>
<option value="2" >active</option>
</select>
I tried with JavaScript:
document.getElementById("status").required = true
and then with jQuery:
$('select[id=status]').prop('required', true);
$('#status').attr('required');
But none of those worked, no error, nothing.
Edit: this problem is specific to <select>
. With <input>
it works fine.