Try setting the data-val attributes on the item, then you have to tell jQuery you have new content to re-parse the form via something like: $.validator.unobtrusive.parse($('#yourForm'));其中form当然是对form元素的引用.where form is of course a reference to your form element.也有一篇很棒的文章,jQuery有一些您可以调用的内部适配器:来自 http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-2There is also this great posting and jQuery has a few internal adapters you can call:from http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-2jQuery.validator.unobtrusive.adapters.addSingleVal("notequalto", "otherproperty", "mynotequaltofunction") 这篇关于如何在没有数据注释的情况下使字段为必填项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-15 13:03