Foolproof RequiredIf状态为false状态不起作用

时间:2015-11-26 11:01:50

标签: c# validation foolproof-validation

我有一个JoinStatus字段True or False条件。我还有2个名为JoiningDateNotJoiningReason的文本框。如果用户选中复选框(True Condition),JoiningDate textbox应该验证其他(False ConditionNotJoiningReason 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>

0 个答案:

没有答案