ASP.NET MVC 3:动态/ AJAX内容不显眼的客户端验证所需的步骤 [英] ASP.NET MVC 3: Required steps for unobtrusive client-side validation of dynamic/AJAX content

查看:103
本文介绍了ASP.NET MVC 3:动态/ AJAX内容不显眼的客户端验证所需的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是全套的步骤所需作为客户端不引人注目的验证,为动态插入表单字段工作?

What are the complete set of Steps Required for client-side unobtrusive validation to work for dynamically inserted form fields?

<一个href=\"http://stackoverflow.com/questions/6124992/asp-net-mvc-3-unobtrusive-client-side-validation-with-dynamic-content\">ASP.NET MVC 3动态内容不显眼的客户端验证 - 他需要在不显眼的属性验证,在生成的HTML展现出来,并通过调用这样做 BeginForm

ASP.NET MVC 3 unobtrusive client-side validation with dynamic content - He needed the unobtrusive validation attributes to show up in the generated HTML and did so by calling BeginForm

ASP.Net MVC上当作ajaxForm 3验证 - 提问者使用 Ajax.BeginForm 它使用MicrosoftAjax而不是JQuery.validation。

ASP.Net MVC 3 validation on AjaxForm - The asker was using Ajax.BeginForm which uses MicrosoftAjax instead of JQuery.validation.

<一个href=\"http://stackoverflow.com/questions/4187742/partialview-and-unobtrusive-client-validation-not-working\">PartialView和不显眼客户端验证工作不 - 他与不显眼的验证问题的属性没有显示出来,并压倒了 ViewContext.FormContext 作为一种解决方法

PartialView and unobtrusive client validation not working - He had the problem with unobtrusive validation attributes not showing up and overrode ViewContext.FormContext as a workaround.

<一个href=\"http://stackoverflow.com/questions/4997269/asp-net-mvc-3-generate-unobtrusive-validation-when-beginform-is-on-the-layout\">ASP.NET MVC 3:生成不显眼的审定时BeginForm是在布局 - 解决方法不显眼的验证属性不显示HTML高达

ASP.NET MVC 3: Generate unobtrusive validation when BeginForm is on the layout - Workaround for unobtrusive validation attributes not showing up in HTML

在ASP.NET MVC布拉德·威尔逊的不显眼的客户端验证3

Brad Wilson's Unobtrusive Client Validation in ASP.NET MVC 3

完全指南为了验证在ASP.NET MVC 3 - 第1部分

完全指南为了验证在ASP.NET MVC 3 - 第2部分

<一个href=\"http://weblogs.asp.net/imranbaloch/archive/2011/03/05/unobtrusive-client-side-validation-with-dynamic-contents-in-asp-net-mvc.aspx\">Unobtrusive客户端验证与ASP.NET MVC 3 动态内​​容

推荐答案

在这一点上,我相信下面的是一套完整的要求:

At this point I believe the following is a complete set of requirements:


  1. 创建与 Html.BeginForm 表格

  2. 打开 ClientValidationEnabled

  3. 打开 UnobtrusiveJavaScriptEnabled

  4. 设置适当的验证对模型的属性的属性(的的字段)

  5. 如果正在使用的HTML辅助创建表单元素是不一样的形式 Html.BeginForm 呼叫,使用相应的解决方法(见<一href=\"http://stackoverflow.com/questions/4187742/partialview-and-unobtrusive-client-validation-not-working\">workaround 1 和<一个href=\"http://stackoverflow.com/questions/4997269/asp-net-mvc-3-generate-unobtrusive-validation-when-beginform-is-on-the-layout\">workaround 2 )

  6. 包含的jQuery jquery.validate.js jquery.validate.unobtrusive .js文件文件,顺序

  7. 验证不显眼的验证属性在HTML present

  8. 如果使用自定义验证:

    • 确保它们添加到 jQuery.validator.unobtrusive.adapters

    • 确保它们通过调用添加到jQuery的验证插件 jQuery.validator.addMethod

    • 确保上述前发生 $(文件)。就绪()作为在这一点为时已晚

  1. Create a form with Html.BeginForm
  2. Turn on ClientValidationEnabled
  3. Turn on UnobtrusiveJavaScriptEnabled
  4. Set appropriate validation attributes on the model's properties (not fields)
  5. If the Html Helpers being used to create the form elements are not on the same form as the Html.BeginForm call, use a relevant workaround (see workaround 1 and workaround 2)
  6. Include jquery, jquery.validate.js, and jquery.validate.unobtrusive.js files, in that order
  7. Verify that the unobtrusive validation attributes are present in the HTML
  8. If using custom validators:
    • ensure that they are added to jQuery.validator.unobtrusive.adapters
    • ensure that they are added to the jQuery validation plugin by calling jQuery.validator.addMethod.
    • ensure that the above happen before $(document).ready() as at that point it's too late

这篇关于ASP.NET MVC 3:动态/ AJAX内容不显眼的客户端验证所需的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆