选中复选框时在文本框上进行验证 [英] To put validation on textbox when checkbox is selected

查看:100
本文介绍了选中复选框时在文本框上进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试在用户选中复选框时将验证放在与复选框相关联的文本框中,然后验证应该可以工作,否则无法正常工作.这也与asp.net中的一个validationgroup有关.如果我单击该按钮,则必须对其进行检查,还有一件事是我不能将我的js代码放在.aspx文件中,它必须放在单独的.js文件中,因此请告诉我如何可以放置一个验证而不浪费实验时间,必须在客户端.

谢谢!

Hi all,

I am trying to put validation on a textbox it is associated with a checkbox when user checked checkbox then validation should work otherwise not. And this is also related to a validationgroup in asp.net. If I click on the button then it must be checked and one more thing is that i can''t put my js code in .aspx file it must be in separate .js file so please tell how can put wright one validation not to waste time in experimenting and it must be at client side.

Thanks!

推荐答案

sat_dev,

您可以在单独的文件中使用JavaScript进行验证,在文件中编写JavaScript并将其存储为"FileName.js",然后按如下所述将Javascript文件包含在.aspx文件的标题中,


Hi sat_dev ,

you can use JavaScript for your Validation in a separate file itself , Write a JavaScript in a file and store it as like ''FileName.js'' and then include the Javascript file in the header of your .aspx file as mentioned below ,





试试这个
Hi,

just try this
   function f1()
{
    if(document.getElementbyID("rdb").checked)
{
     //call validation method which is placed in another js file
}
else
{

}
}



最好的



All the Best


这篇关于选中复选框时在文本框上进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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