With the code below I show or hide two divs based on dropdown selection. My question is how can I make the div thar is shown to have the textbox required ?
$(document).ready(function(){
$("#europerkg").hide();
$("#flatfee").hide();
$('#rate').on('change', function() {
if (this.value == '1') {
$("#europerkg").show();
$("#flatfee").hide();
}
if (this.value == '2') {
$("#europerkg").hide();
$("#flatfee").show();
}
if (this.value == '3') {
$("#europerkg").show();
$("#flatfee").show();
}
});
});
<div class="col-md-3" id="europerkg">
<label class="form-label">€ / kg</label>
<input name="europerkg" id="europerkg" type="text" class="form-control" placeholder="">
</div>
<div class="col-md-3" id="flatfee">
<label class="form-label">Flat Fee</label>
<input name="flatfee" id="flatfee" type="text" class="form-control" placeholder="">
</div>