简体   繁体   English

哪个必填字段验证器失败?

[英]which required field validator failed?

So I have a couple of forms done in asp.net/c# that I need to validate. 因此,我需要验证一些在asp.net/c#中完成的表格。 If one of the validators fails, I'd like to change the class for the text box and the label on the client side/post back. 如果验证程序之一失败,我想更改文本框和客户端/回发标签上的类。 The way I'd usually do this is by manually validating the forms client side and server side. 我通常这样做的方式是通过手动验证客户端和服务器端的表单。 Is there a way to do this using validators instead of a bunch of if statements? 有没有一种方法可以使用验证器来代替一堆if语句?

You can use the standard asp.net validators for the client side that will potentially give you some text next to the field or within the validation summary. 您可以在客户端使用标准的asp.net验证器,这可能会在字段旁边或验证摘要中为您提供一些文本。 There are some 3rd party plugins that you might be able to utilize that will take this a step further in regards to custom CSS styling, etc. 您可能可以使用一些第三方插件,这将在自定义CSS样式等方面更进一步。

Take a look at these alternatives to the .NET validators: 看一下.NET验证程序的以下替代方法:

Generally speaking this is precisely what validators are for. 一般来说,这正是验证程序的用途。 But the client-side validation may not necessarily just change the field's class (presumable to change its colour). 但是客户端验证可能不一定只是更改字段的类(可能会更改其颜色)。 How important is that way of indicating a validation problem? 指示验证问题的方式有多重要?

所需的字段验证器扩展程序控件是您想要的。

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

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