我无法让我的客户端数据注释正常工作。

时间:2018-07-13 12:56:30

标签: asp.net-mvc validation data-annotations server-side

这是我的ViewModel

let $doc := <root>
          <date>12/31/2016</date>
         </root>


let $date := fn:format-date(xs:date(xdmp:parse-dateTime([Y0001]/[M01]/[D01]",$doc/date/text())),"[Y0001]/[M01]/[D01]")
let $today := fn:format-date(fn:current-date(),"[Y0001]/[M01]/[D01]")
return $date le $today

我的观点

    public class LoginViewModel
{
    [Required(ErrorMessage = "Username is required")]
    [Display(Name = "Username")]
    public string Username { get; set; }

    [Required(ErrorMessage = "Password is required")]
    [Display(Name = "Password")]
    public string Password { get; set; }
}

我的控制器

    <div class="container">


    <form class="form-atk">
        <h3 class="form-atk-heading">Please Sign In</h3>
        @using (Html.BeginForm())
        {
            <div class="form-atk">       
                @Html.TextBoxFor(m => m.Username, new { @class = "form-control", @placeholder = "Email" })
                @Html.ValidationMessageFor(m => m.Username, string.Empty, new { @class = "text-danger" })
                </div>
            <div class="form-atk">
                @Html.TextBoxFor(m => m.Password, new { @class = "form-control", @placeholder = "Password" })
                @Html.ValidationMessageFor(m => m.Password, string.Empty, new { @class = "text-danger" })
                </div>

            <a id="btnLogin" class="btn btn-primary btn-lg btn-block" href="@Url.Action("Landing", "Start")">Login </a>
        }
        <div class="form-atk" style="text-align:center">           
        <link >@Html.ActionLink("Create Account","CreateAccount","Login")<link>
        </div>
        <div class="form-atk" style="text-align:center">           
        <link >@Html.ActionLink("Forgot Password","ForgotPassword","Login")<link>
        </div>

每次我单击“登录”按钮时,无论如何我都无法进行任何验证,即使我在设置为所需的文本框中没有任何内容也无法进入下一页。视图模型。

0 个答案:

没有答案