我有一个JoinStatus
字段True or False
条件。我还有2个名为JoiningDate
和NotJoiningReason
的文本框。如果用户选中复选框(True Condition
),JoiningDate textbox
应该验证其他(False Condition
)NotJoiningReason textbox
应该验证。
我正在尝试使用Foolproof实现此目的,但问题是False Condition
未得到验证。
视图模型
public bool JoinStatus { get; set; }
[RequiredIf("JoinStatus",true,ErrorMessage="foooooooooooooooo")]
public DateTime? JoinDate { get; set; }
[RequiredIf("JoinStatus",false, ErrorMessage = "foooooooooooooooo111111111111")]
public string NotJoiningReason { get; set; }
HTML
@Html.CheckBoxFor(m => m.JoinStatus, new { @class = "chkbxSwitchReverse", @id = "chkbxJoinStatus", })
@Html.TextBoxFor(m => m.JoinDate,
new { @class = "form-control", @placeholder = "Specify Month ", @id = "txtJoinDate",@readonly=true, @style = "background-color:white" })
@Html.TextAreaFor(m => m.NotJoiningReason
new { @class = "form-control ", @id = "txtNotJoiningReason", @placeholder = "Not joining reason" })
JavaScript
<script src="~/plugins/foolproofValidation/mvcfoolproof.unobtrusive.min.js"></script>
<script src="~/plugins/foolproofValidation/MvcFoolproofJQueryValidation.min.js"></script>
<script src="~/plugins/foolproofValidation/MvcFoolproofValidation.min.js"></script>