客户端验证无效

时间:2014-04-06 09:46:24

标签: javascript asp.net-mvc-4 client-side-validation

我的客户端验证无法处理更新

我的脚本处于正确的顺序......(我根据教程编写了它们)
我的浏览器(Chrome)启用了javascript

Web.Config文件

<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

修改视图:

@model MultipleRowsDemo.Models.Employee

@{
    ViewBag.Title = "Edit";
}
<script src="~/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Employee</legend>

        @Html.HiddenFor(model => model.Id)

        <div class="editor-label">
            @Html.LabelFor(model => model.FUllName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FUllName)
            @Html.ValidationMessageFor(model => model.FUllName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Gender)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Gender)
            @Html.ValidationMessageFor(model => model.Gender)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.AGE)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.AGE)
            @Html.ValidationMessageFor(model => model.AGE)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.HireDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.HireDate)
            @Html.ValidationMessageFor(model => model.HireDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.EmailAddress)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EmailAddress)
            @Html.ValidationMessageFor(model => model.EmailAddress)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Salary)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Salary)
            @Html.ValidationMessageFor(model => model.Salary)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PersonalWebSite)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PersonalWebSite)
            @Html.ValidationMessageFor(model => model.PersonalWebSite)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Photo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Photo)
            @Html.ValidationMessageFor(model => model.Photo)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.AlternateText)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.AlternateText)
            @Html.ValidationMessageFor(model => model.AlternateText)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

类似的帖子:

  

asp.net mvc client side validation not working?

     

MVC 4 Client side validation not working

这篇文章建议脚本应该是正确的顺序

  

jquery client side validation not working in MVC3 partial view   MVC3-局部视图

这个问题是关于局部视图......我没有那个

请建议

1 个答案:

答案 0 :(得分:-1)

如果您有_Layout或母版页,则可以在此处保留脚本链接。