必填字段验证器可见false [英] required field validator visible false

查看:79
本文介绍了必填字段验证器可见false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..有谁能帮助我.
我对必填字段验证器有疑问.实际上,我有一份注册表,并且有一些字段,例如(全名,姓氏,d.o.b等).
有一个复选框,当我选中该复选框时,我想要的是我在全名或姓氏可见性上应用的必需验证器将被隐藏.我的意思是行不通.其余所有必需的字段验证器将起作用.请帮助我..

hi.. is there any one who can help me.
i have a problem with required field validator. actually i have a registration form and there are some fields like(full name. last name , d.o.b, etc).
there is a check box and what i want that when i check that checkbox the required validator that i have applied on full name or last name visiblity will be hidden. i mean will not work. and rest of all required field validator will work.pls help me out..

推荐答案

首先检查验证组 ...
在必填字段中检查 Display ="None" .
First check for validation group...
check for Display="None" in required field.



转到复选框的已选中已更改事件,并禁用RequireFieldValidator(确保CheckBox AutoPostBack 属性设置为true).试试这个:
Hi,
Go to the checked changed event of your checkbox and disable the RequireFieldValidator(make sure the AutoPostBack property of your CheckBox is set to true). Try this:
protected void checbox1_CheckChanged(object sender, EventArgs e)
{
    if(checkbox1.Checked)
    {
        //Suppose your first name RequiredFieldValidator's id is RequiredFieldValidator1
        //And your last name RequiredFieldValidator's id is RequiredFieldValidator2
        RequiredFieldValidator1.Visible = false;
        RequiredFieldValidator2.Visible = false;
    }
    else
    {
        RequiredFieldValidator1.Visible = false;
        RequiredFieldValidator2.Visible = false;
    }
}





--Amit





--Amit


您好

您还可以尝试使用自定义验证程序尝试另一种解决方案(如果要在客户端进行所有操作).在验证功能中,您可以检查是否已选中该复选框,然后根据该检查来检查您的字段.

请查看链接,然后转到自定义验证器"部分

http://msdn.microsoft.com/en-us/library/aa479013.aspx [ ^ ]

希望对您有帮助.
Hi

There is another solution you can try (if you want to make this all in client side ) with custom validator. In the validation function you can check if the check box is checked or not and then check your field based on the check.

Please see the link and go to "Custom Validator" Section

http://msdn.microsoft.com/en-us/library/aa479013.aspx[^]

Hope this will help you.


这篇关于必填字段验证器可见false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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