繁体   English   中英

jQuery验证选项不起作用MVC3剃刀

[英]JQuery Validate Options not working MVC3 Razor

我试图让一个简单的忽略工作为JQuery验证,我似乎无法使其工作。 不管我做什么,似乎都不使用这些选项。 我已经修剪了代码并粘贴到下面。 谢谢你的帮助。

我正在使用MVC3 Razor和JQuery 1.5.1

@Code
    ViewData("Title") = "Index"
    Layout = "~/Areas/Quote/Views/Shared/_Layout.vbhtml"
End Code
<script type="text/javascript">
    $(document).ready(function () {
        $('#myform').validate({
            ignore: "#textx"
        })
    });
</script>
@Using Html.BeginForm("Index", "YourQuote", FormMethod.Post, New With {.id = "myform"})
    @<input  type="text" id="textx" class="required"/>
    @<input type="submit" value="save" />
End Using

谢谢回复。 该示例已简化,但是我真正想做的是有一个覆盖规则,该规则说忽略验证中的所有隐藏元素。 我的页面是动态构建的,删除类并在隐藏或显示父元素时将其重新添加对我不利

@Code
    ViewData("Title") = "Index"
    Layout = "~/Areas/Quote/Views/Shared/_Layout.vbhtml"
End Code
<script type="text/javascript">
    $(document).ready(function () {
        $('#myform').validate({
            ignore: ":hidden"
        })
    });
</script>
@Using Html.BeginForm("Index", "YourQuote", FormMethod.Post, New With {.id = "myform"})
    @<div style="display:none">
    <input  type="text" id="textx" class="required"/>
    </div>
    @<input type="submit" value="save" />
End Using

尝试删除不引人注目的jquery包含,仅包含jquery.validate。 我遇到了类似的问题,并且不扰人的库搞砸了我的自定义定义设置

required类是否与忽略设置冲突? 当您想忽略该字段时,请尝试删除该类(即,如果您有条件地忽略该字段,则需要在适当的时候在回调或类似方法中使用.removeClass() )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM