验证两个下拉列表 [英] validation on two dropdownlist

查看:58
本文介绍了验证两个下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有两个下拉列表。我在两个上面放了requirefield。

i必须这样做....

当我点击提交按钮,如果我已选择其中一个,然后验证不会触发第二个下拉列表。我必须在我提交数据时只填充一个下拉列表。但验证两个.how解决此问题。

I have two dropdown in on page.I put requirefield on both.
i have to do like this ....
when i click on submit button, if i have select one of them, then validation will not fire second dropdown .i have to fill only one dropdown when i submit data.But validation fire on both .how to solve this problem.

推荐答案

在页面提交时,引发一个JS方法。在其中,找到两个下拉列表的选定值。如果您发现其中任何一个有价值,请让页面回发。如果你发现两个都没有被选中,请提高警报并取消回发。



试用。
On page submit, raise a JS method. In it, find the selected value of both dropdowns. If you find any one of them having value, let the page postback. If you find both of them not selected, raise an alert and cancel postback.

Try out.


if(drp_list1.text==""){MessageBox.Show("Enter Data");return;}
if(drp_list2.text==""){MessageBox.Show("Enter Data");return;}



试试这个。


Try this.


你可以将DropDown的CausesValidation属性切换为True / False。
you can switch CausesValidation property of DropDown to True/False.


这篇关于验证两个下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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