I have create courses Model to add courses and watch it....there is field in create form named "IsPaid"...it is boolean variable ....when I press on "IsPaid" it leads to open new field named "CourseFees" ... when anyone press "IsPaid" and put fees of course in "CourseFees" field if this one change IsPaid from "true" to "false" the proplem is "CourseFees" field It will not be empty....how to access boolean value in jQuery to make "CourseFees" field empty when "IsPaid" value "false"
here is code in create view:
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="IsPaid" id="ispaid" /> @Html.DisplayNameFor(model => model.IsPaid)
</label>
</div>
</div>
<div class="form-group" id="crsfees">
<label asp-for="CourseFees" class="control-label"></label>
<input value="0.00" palceholder="0.00" asp-for="CourseFees" class="form-control" />
<span asp-validation-for="CourseFees" class="text-danger"></span>
</div>
my wrong code in jQuery:
<script>
$(document).ready(function () {
$("#crsfees").hide();
$(document).on('change', '#IsPaid', function (e) {
var selected = $(this).val();
if (selected == false) {
$("#crsfees").val()=0.00;
}
});
});
</script>