单个文本框可以有多个验证....... [英] can single textbox have multiple validations.......

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

问题描述

例如...
我有一个下拉列表作为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......

推荐答案

是的.如果我说对了,请尝试这样的事情:
Yes you can. Try something like this if I am getting you right:
if(dropDownList1.SelectedIndex == 1)
{
  //call function say characterValidation();
}
else if(dropDownList1.SelectedIndex == 2)
   {
      //call function say numericValidation();
   }


等等.




当然有可能.您可以使用Custom Validator.这将接受javascript函数作为验证函数,并且基于验证,您必须将IsValid设置为True或False.

尝试这样,

Hi,

ofcourse it is possible. You can use Custom Validator. this will accept the javascript function as validation function and based on the validation you have to set IsValid to True or False.

try like this,

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;
}



检查 [



check this[^] for more on Custom validators. Set the ClientValidationFunction to above javascript function.

hope it helps.


这篇关于单个文本框可以有多个验证.......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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