C#点网验证帮助 [英] C# dot net Validation help

查看:85
本文介绍了C#点网验证帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我遇到了一个非常复杂的问题,实际上我正在制作一个网站,并且有10个TextBoxes
一张桌子中的5吨,另一张桌子中的5吨
像这样的东西

http://i52.tinypic.com/2qw0g2g.jpg


█████BOX1██████████BOX6█████
█████BOX2██████████BOX7█████
█████BOX3██████████BOX8█████
█████BOX4██████████BOX9█████
█████BOX5██████████BOX10████


现在的问题是我想验证Box6和Box7的值.

条件是:
如果BOX2已填充,则BOX6和BOX7也应填充.
如果填充了BOX3,则必须填写BOX6和BOX8.
如果填充了BOX4,则必须填写BOX6和BOX9.

现在,如果有人在BOX1下面的任何一个框中填充,则应该贴上标签,说我上面提到的各个框也是必须的.

如何使用javascript或其他任何方式?

Hello guys I am struck in a very complicated problem,actually I am making a website and there are 10 TextBoxes
5 in one td of a table and 5 in the other td
something like this

http://i52.tinypic.com/2qw0g2g.jpg


█████BOX1█████ █████BOX6█████
█████BOX2█████ █████BOX7█████
█████BOX3█████ █████BOX8█████
█████BOX4█████ █████BOX9█████
█████BOX5█████ █████BOX10████


Now the problem is that I want to validate Box6 and Box7 for values.

The conditions is that:
If BOX2 is filled then BOX6 AND BOX7 should also be filled.
If BOX3 is filled then BOX6 AND BOX8 is compulsory.
If BOX4 is filled then BOX6 and BOX 9 are compulsory.

Now if someone fills any of the box below BOX1 then a label should come saying the respective boxes I mentioned above are also mandatory.

How can I do it using javascript or any other way?

推荐答案

您可以使用.Net的内置验证功能.为了指示必填字段,通常的做法是在其旁边加上一个红色星号(就像您在网上购买商品并填写表格的信用卡部分一样.以下链接将为您提供超过900万用于检查有关asp.net验证的信息的链接:

http://www.google.com/search?q=asp.net+validation&sourceid=ie7&rls=com.microsoft:zh-cn:IE-SearchBox&ie=&oe= [ ^ ]
You can use the built-in validation capabilities of .Net. To indicate a required field, the common practice is to put a red asterisk next to it (kind of like when you are purchasing something online, and are filling out the credit card portion of the form. The following link will give you over 9 million links to check for info regarding asp.net validation:

http://www.google.com/search?q=asp.net+validation&sourceid=ie7&rls=com.microsoft:en-us:IE-SearchBox&ie=&oe=[^]


我只会在文本框上使用RequiredFieldValidators.仅此一项是不够的,因为您的条件要复杂一些.您还必须在文本框上启用自动回发,并跟踪它们何时被填充(或再次清空),然后在其他框中启用或禁用验证器.

另外,也许不太复杂的设计(如具有多个页面的向导)可以以更加用户友好的方式达到您的目标.
I would simply use RequiredFieldValidators on the textboxes. This alone will not suffice, as your conditions are a bit more complex. You must additionally enable auto postback on the textboxes and keep track when they are filled (or emptied again) and then enable or disable the validators on the other boxes.

Alternatively, perhaps a less complicated design (like a wizard with several pages) can reach your goal in a more user friendly fashion.


这篇关于C#点网验证帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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