I am currently creating a MVC project that takes in data from a form/view generated from the model.
I want to be able to check user input in the form. If that input is less than 1, it would trigger another panel of information to open. The code below isn't quite functioning correctly. How exactly do I make this happen?
In my View:
<div class="form-group">
@Html.LabelFor(model => model.Buy2Yearsataddress, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10" id="coBuyerYearsAtAddress">
@Html.EditorFor(model => model.Buy2Yearsataddress, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Buy2Yearsataddress, "", new { @class = "text-danger" })
</div>
</div>
And here's what's in my script file:
$("#coBuyerYearsAtAddress").focusout(function () {
if ($("#coBuyerYearsAtAddress").val() <= 1) {
$('#coBuyerPreviousResidence').show();
}
else {
$('#coBuyerPreviousResidence').hide();
}
});