问题标签 [validation]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
763 浏览

wpf - Is this a crazy way to handle multi Validation types with IDataError and WPF?

We are using the standard method for our controls to report broken BO rules. This is done via the interface IDataError in our BO’s and in XAML the control is bound to the BO’s property etc. This approach works OK. But we need to show 2 types of visuals in the UI depending on the type (or category if you like) of the invalidation error. If it’s a required field then we show a CueBanner (water mark) but for other types we change the colour of the controls boarder. In both scenarios we set the tool type of the error message.

The Problem with IDataError is that it doesn’t support a method/property to distinguish between error types.

The only way I can do that is by examining the error text, required field text must contain the key word “required”. The following approach doesn’t feel right but it’s the only way I can determine the type of error and then deal with it accordingly. All required field rules must have as part of the error text “required field”. To make this all work I have created a custom dependency property called ErrorMessage. In my ResourceDictionary I have a Style.Trigger for Validation.HasError. In there I set my dependency properties value to the ErrorContent. Now when my dependency properties value changes I can examine the text and set the Validation.SetErrorTemplate( myControl, newErrorTemplate) to the template to suit the error type. I have to wire up a few events to the control such as lost and got focus to manage removing or adding the cueBanner template but the whole thing will work. It’s just that I’m not sure it’s the best way to do it.

PS. When I set the ErrorTemplate i’m doing this in code, thats building and adding it. Is there a way to point Validation.SetErrorTemplate to a static resource keeping in mind that I need to switch between at least 2 types?

Your thoughts please..

0 投票
7 回答
22141 浏览

javascript - JQuery.Validate 插件可以阻止提交 Ajax 表单吗

我正在使用 JQuery 表单插件 ( http://malsup.com/jquery/form/ ) 来处理表单的 ajax 提交。我还插入了 JQuery.Validate ( http://docs.jquery.com/Plugins/Validation ) 以进行客户端验证。

我所看到的是,当我期望验证失败时,它不会阻止表单提交。当我使用传统表单(即非ajax)时,验证失败完全阻止了表单提交......这是我想要的行为。

我知道验证已正确连接,因为在 ajax 提交发生后仍会出现验证消息。

那么我错过了什么阻止了我想要的行为?下面的示例代码......

0 投票
6 回答
4887 浏览

c# - 是否有使用属性的 .NET 参数验证标准框架?

是否有允许您在方法属性中进行通用参数验证的标准框架(可能是企业库的一部分......或 .NET 本身)?

0 投票
2 回答
7924 浏览

asp.net - 如何动态设置 ValidationGroup

我有一个带有 2 个用户控件 (.ascx) 的 ASP.NET 2.0 网页。每个 UserControl 都包含一堆验证器。在页面上放置 ValidationSummary 将显示两个 UserControl 的所有验证错误。在每个 UserControl 中放置一个 ValidationSummary 将显示两个控件的所有错误两次。

我想要的是每个 UserControl 的 ValidationSummary,只显示该 UserControl 上的错误。

我试图通过在每个用户控件上动态设置验证器的 ValidationGroup 属性来解决这个问题。这样每个验证摘要应该只显示其用户控件的错误。我用过这段代码:

然而,这似乎禁用了客户端和服务器端验证,因为提交表单时不会发生验证。

帮助?

0 投票
8 回答
36723 浏览

asp.net - ASP.NET:无法验证数据

ASP.NET 中此异常的原因是什么?显然这是一个视图状态异常,但我无法在引发异常的页面上重现错误(一个简单的两个 TextBox 表单,带有一个按钮和导航链接)。

FWIW,我没有运行网络农场。

例外

错误消息:无法验证数据。

错误来源:System.Web

错误目标站点:Byte[] GetDecodedData(Byte[], Byte[], Int32, Int32, Int32 ByRef)

发布数据

观点:

/wEPDwULLTE4NTUyODcyMTFkZF96FHxDUAHIY3NOAMRJYZ+CKsnB

事件验证:

/wEWBAK+8ZzHAgKOhZRcApDF79ECAoLch4YMeQ2ayv/Gi76znHooiRyBFrWtwyg=

异常堆栈跟踪

~ 威廉·莱利-兰德

0 投票
8 回答
15513 浏览

java - Eclipse Ganymede 未正确验证 JSP

我刚刚安装了 Ganymede,并且正在探索其中的一个旧项目。我所有的 JSP 都给了我奇怪的验证错误。我看到的东西像 -

我在这里做最佳实践,没有任何脚本或任何东西,所以我认为 Eclipse 错误地将 Java 类验证器应用于我的 JSP。关于如何阻止这种情况发生的任何想法?

在选项/编辑器/文件关联下,我为 JSP 提供了以下内容:

我错过了什么吗?

我也认为这是正确的,但以防万一,这是我的页面指令-

0 投票
2 回答
3590 浏览

java - 验证用户输入 JDBC 的最佳方法?

有没有一种内置的方法来使用 java 中的用户输入转义JDBC?类似于 php 版本mysql_real_escape()功能的东西。验证输入的最佳方法是什么?

0 投票
1 回答
1824 浏览

struts2 - Struts2 无效字符的注解验证器

在使用 Struts2 时,我使用了几个注释在 Model 类中的set()方法中进行验证,例如:

但我想如何进行验证以避免奇怪的字符,如!, ?, #,$等等...

是否有任何现有的验证器我应该像 a 一样使用@RestrictChars,或者是否有某种方法可以使用@StringRegexValidator. 或者我应该写一个新的。任何提示或文档如何做到这一点都会很棒。

0 投票
5 回答
486 浏览

php - 全面的服务器端验证

我目前有一个相当强大的服务器端验证系统,但我正在寻找一些反馈,以确保我已经涵盖了所有方面。以下是我目前正在做的事情的简要概述:

  • 确保输入不为空或太长

  • 转义查询字符串以防止 SQL 注入

  • 使用正则表达式拒绝无效字符(这取决于提交的内容)

  • 编码某些 html 标签,例如 <script> (所有标签在存储在数据库中时都会被编码,有些在被查询以在页面中呈现时被解码)

有什么我想念的吗?欢迎使用代码示例或正则表达式。

0 投票
4 回答
12673 浏览

visual-studio-2008 - 有没有办法将 VS 的 CSS 验证更新到 3.0?

我收到有关 CSS3.0 属性(如文本溢出)的警告。有没有办法针对 3.0 进行验证?


VS2010 在 SP1 中支持 HTML5 和 CSS3。

http://blogs.msdn.com/b/webdevtools/archive/2011/01/27/html5-amp-css3-in-visual-studio-2010-sp1.aspx


现在它在这里。

http://visualstudiogallery.msdn.microsoft.com/7211bcac-091b-4a32-be2d-e797be0db210/view/Reviews/0?showReviewForm=True