动态文本框验证 [英] dynamic textbox validation
问题描述
这是我的表结构2列速率图表和数量:
ratechart数量
1-5 1
6-10 2
11-20 3
我在表格上有3个字段
1个组合框
1个文本框
1个按钮
我通过combobox提取了ratechart列的值,我有相应的代码,但
我的要求是,如果用户从combobbx中选择1-5,则文本框他不能在文本框中输入超过6个.
如果用户从组合框中选择6-10相同,则他不能在文本框中输入超过12个
当他单击保存"按钮时,会收到一个错误,指出数量更多..
提前天才,请帮忙提供代码
this is my table structure 2 column rate chart and qty :
ratechart qty
1-5 1
6-10 2
11-20 3
i have 3 field on form
1 combobox
1 textbox
1 button
i fetch the ratechart column value through combobox , i have that code but
my requirement is if user select 1-5 from combobbx , then textbox he cannot enter more than 6 in textbox.
same if user select 6-10 from combobox , then he cannot enter more than 12 in textbox
while he click on save button he get an error that qty is more..
thx in advance genius please helping for the code
推荐答案
您可以使用范围验证器.在组合框选择更改事件中,在文件后面的代码中动态添加范围验证器.
在选择更改事件方法中,添加以下代码.
Hi,
You can use range validator. Add range validator dynamically in code behind file in combobox selection change event.
In selection change event method Add below code.
if(selected range is 1-5)
{
RangeValidator1.ControlToValidate = "TextboxId";
RangeValidator1.MaximumValue = "Give Max what you want";
RangeValidator1.MinimumValue = " Assign min what you want";
}
else if(selected range is 6-12)
{
RangeValidator1.ControlToValidate = "TextboxId";
RangeValidator1.MaximumValue = "Give Max what you want";
RangeValidator1.MinimumValue = " Assign min what you want";
}
希望对您有所帮助.
Hope this might help you.
这篇关于动态文本框验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!