I'm trying to compare two values of a form. And if they are equal I want to disable the submit button and perhaps display a error field. The focus should be on disabling the button though.
In the code below there is a m.loadingtill and m.loadingfrom field. i would wish to compare these at the button. As you can see I already added some code as how I imagine it could look like. If it has to be done differently, don't mind to do so and explain the how and why.
Can anyone give me insight on how to do this with asp.net with razor 3?
Kind regards
<div class="tf-from-wrapper">
<span class="tf-title">@AddressGeneric.subtitle_timeframes_from_text</span>
@Html.TextBoxFor(m => m.LoadingFrom, new { @class = "form-control", id = "loading-from" })
@Html.ValidationMessageFor(m => m.LoadingFrom, null, new { @class = "text-danger" })
</div>
<div class="tf-till-wrapper">
<span class="tf-title">@AddressGeneric.subtitle_timeframes_till_text</span>
@Html.TextBoxFor(m => m.LoadingTill, new { @class = "form-control", id = "loading-till" })
@Html.ValidationMessageFor(m => m.LoadingTill, null, new { @class = "text-danger" })
</div>
<button type="submit" class="btn btn-primary btn-nav-unloading"
@{
if( compare here m.loadingtill == m.loadingfrom) { @:disabled="disabled"
} }
>Unloading Address <i class="material-icons">keyboard_arrow_right</i></button>