单选按钮列表上的运行时验证 [英] run time validation on a radiobutton list

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

问题描述


首先,祝所有朋友新年快乐.我有一个带有单选按钮列表和文本框的页面.我需要在文本框上进行验证,以便如果单选按钮选择的项目为1,则文本框应接受3个字符,如果单选按钮选择的项目为为2,则texbox应该精确地取10个字符.
在此先感谢.


First of all,happy new year to all my friends.i have a page with a radiobuttonlist and a textbox.I need to put validation on a textbox such that if radiobutton selected item is 1 then textbox should accept 3 characters and if radiobuttonlist selected item is 2,then texbox shoult take exactly 10 characters.
thanks in advance.

推荐答案

为此使用javascript

添加以下功能单选按钮的onclick事件

use javascript for that

add below function onclick event of radio button

<script type="text/javascript">
function validate(ctr)
{
try
{
if (ctr.checked)
{
var txt=document.getElementByID(txtboxid).value;

if (txt.lenght>3 )
{
document.getElementByID(txtboxid).value='';
alert('TextBox lenght should be less than 10 character');
}
}

}
catch(Error)
{
alert(Error);
}

}


这篇关于单选按钮列表上的运行时验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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