本文介绍了单个文本框可以有多个验证.......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如...
我有一个下拉列表作为client1 client2 client3 ........ client10
和一个文本框
&&
对于每个选定的dropdownitem文本框,是否应该执行不同的验证……
eg...
i have a dropdownlist as client1 client2 client3........client10
and one textbox
&&
for each selected dropdownitem textbox should perform different validations is it possible......
推荐答案
if(dropDownList1.SelectedIndex == 1)
{
//call function say characterValidation();
}
else if(dropDownList1.SelectedIndex == 2)
{
//call function say numericValidation();
}
等等.
function fnValidate(sender,args)
{
var ddl = document.getElementById("dropdownList1");
if(ddl.options.value == "client1")
{
var txt = document.getElementById("Textbox1");
//validate text box
args.IsValid=true; //based on the validation set the true or false.
}
elseif(ddl.options.value == "client2")
{
var txt = document.getElementById("Textbox1");
//validate text box
args.IsValid=true; //based on the validation set the true or false.
}
return;
}
检查此 [ ^ ]有关自定义验证程序的更多信息.将ClientValidationFunction
设置为上述javascript函数.
希望对您有所帮助.
check this[^] for more on Custom validators. Set the ClientValidationFunction
to above javascript function.
hope it helps.
这篇关于单个文本框可以有多个验证.......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!