我想获得一个简单的忽略工作的JQuery验证,我似乎无法得到它的工作。无论我做什么,似乎都不使用这些选项。我修剪了代码并粘贴在下面。谢谢你的帮助。JQuery验证选项不工作MVC3 Razor
我使用MVC3剃刀和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
非常好,谢谢serrghi。这似乎已经成功了。你是怎么弄出来的?我该如何标记这个答案? –
将我的评论更改为回复:)很高兴为您解决 – tskulbru