JSFiddle - React, Tailwind, and code Playground

by TrueBlueAussie

HTML

<select name="CustomerType" id="CustomerType" class="form-control" onchange="CustomerTypeChange()">
    <option value="10" selected="true">Company</option>
    <option value="20" selected="false">Person</option>
</select>

<input type="text" name="TaxNumber" id="TaxNumber" class="form-control parsley-validated"/>

CSS

.box {
    border: 1px solid red;
    height: 200px;
    overflow: auto;
}

.box-inner {
    height: 400px;
}

JavaScript

var CustomerTypeChange = function () {
    var customerType = document.getElementById("CustomerType").value;
    if (customerType == 10) {
        $('#TaxNumber').attr("data-required", 'false');
    }
    if (customerType == 20) {
        $("#TaxNumber").attr("data-required", 'true');
    }
}