HTML
<select name="CustomerType" id="CustomerType" class="form-control" onchange="CustomerTypeChange()">
<option value="@((int)THOS.Utilities.Enumerations.Enumerations.Customer.CustomerType.Company)" selected="@(Model != null ? (Model.CustomerType == (int)THOS.Utilities.Enumerations.Enumerations.Customer.CustomerType.Company):true)">Company</option>
<option value="@((int)THOS.Utilities.Enumerations.Enumerations.Customer.CustomerType.Person)" selected="@(Model != null ? ((Model.CustomerType == (int)THOS.Utilities.Enumerations.Enumerations.Customer.CustomerType.Person)) : false)">Person</option>
</select>
<input type="text" name="TaxNumber" id="TaxNumber" class="form-control parsley-validated">
When CustomerType change below js code runs
Javascript Code:
function CustomerTypeChange() {
var customerType = document.getElementById("CustomerType").value;
if (customerType == 10) {
$('#TaxNumber').attr("data-required", 'false');
}
if (customerType == 20) {
$("#TaxNumber").attr("data-required", 'true');
}
}
When i add TaxNumber attribute true/false attr("data-required", true) or attr("data-required", false) never works .
Edited:
$("#TaxNumber").data('data-required', true); does not work too
$("#TaxNumber").data('required', true); does not work too
If i check browser console there is no any error where i miss exactly ?
Thanks.