Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
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.
Posted

1 solution

use javascript for that

add below function onclick event of radio button

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

}
 
Share this answer
 
v2
Comments
hitech_s 2-Jan-12 4:09am    
added pretags

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900