I had one field something like Holiday such that is given below,
[StringLength(50)]
[DisplayName(Constants.DisplayName.HolidayDay)]
public virtual string HolidayDay { get; set; }
And
public virtual enumHolidayDay enumHolidayDay
{
get
{
return (enumHolidayDay)Enum.Parse(typeof(enumHolidayDay), HolidayDay);
}
set
{
HolidayDay = value.ToString();
}
}
And
public enum enumHolidayDay
{
[Description("Saturday")]
saturday = 1,
[Description("Sunday")]
sunday = 2,
}
And my Holiday.cshtml file is following
<div class="row">
<div class="col-md-3">
<label for="" class="control-label">
Set Holiday For </label><br />
@Html.EnumCheckBoxFor(m => m.enumHolidayDay)
</div>
</div>
<br/>
<div class="row">
<div class="col-md-3">
<label for="" class="control-label">
Day</label><br />
@Html.TextBoxFor(model => model.HolidayDay, new { @class = "form-control"
}).DisableIf(() => Model.IsReadOnly == true)
</div>
</div>
On my screen there are two checkboxes named Saturday and another one is Sunday. And one textbox named Day, But user can enter data in either one of it. One is mandatory. How to handle them, i.e. How to disable the Day field when the user click the any checkbox. And the Holiday field only used to these controls. In which event i have to handle it without using scripts and what are the code i need to add for this. Can anyone please help to find the solution...
Check bellow code
With jQUery
Updated Without jQUery