Asp.net mvc 3 客户端验证不使用外键

Asp.net mvc 3 客户端验证不使用外键,asp.net-mvc-3,Asp.net Mvc 3,客户端验证仅对外键无效 我有 <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 有什么想法吗

客户端验证仅对外键无效

我有

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
有什么想法吗?我已经搜索了一个解决方案,但我所发现的都是它根本不起作用的情况,大多数解决方案都说要确保上述两个脚本都是源代码,并将上述两个键添加到web.conifg文件中

我没有收到js错误,我已经用firebug进行了监控。一切似乎都很完美,但显然并非如此

更正非外键字段并重新提交后,数据验证将在服务器端工作。这是一个问题,因为它创建了双重验证,让用户非常恼火

非常感谢你的帮助

下面是Html部分。它包含在使用块中。这是标准的MVC3生成的CRUD代码

<div class="editor-label">
    <label for="FiscalYearId">Fiscal Year</label>
</div>
<div class="editor-field">
    <select id="FiscalYearId" name="FiscalYearId">
        <option value="">---Select Fiscal Year---</option>
        <option value="1">FY2013</option>
    </select>
    <span class="field-validation-valid" data-valmsg-for="FiscalYearId" data-valmsg-replace="true"></span>
</div>

会计年度
---选择会计年度---
2013财年

我认为html中没有元数据属性。在您的视图中尝试以下操作:

if (this.ViewContext.FormContext == null) 
{
    this.ViewContext.FormContext = new FormContext(); 
}

您能否检查生成的HTML并将其发布到FiscalYearId下拉列表中?另外,请使用(Html.BeginForm()){}块确保表单元素位于
@内。使用Html更新了我的问题,select没有验证属性,这不是javascriptproblem@karaxuna“选择”没有验证属性是什么意思?呈现的“选择”html必须如下所示才能进行验证:。。。你试过我的解决方案吗?我试过了,但是运气不好。你是在html.BeginForm中发布的html吗?
<div class="editor-label">
    <label for="FiscalYearId">Fiscal Year</label>
</div>
<div class="editor-field">
    <select id="FiscalYearId" name="FiscalYearId">
        <option value="">---Select Fiscal Year---</option>
        <option value="1">FY2013</option>
    </select>
    <span class="field-validation-valid" data-valmsg-for="FiscalYearId" data-valmsg-replace="true"></span>
</div>
if (this.ViewContext.FormContext == null) 
{
    this.ViewContext.FormContext = new FormContext(); 
}