Click here to Skip to main content
15,668,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i want to disable validations to dropdown lists when my check box is unchecked and it should enable when my check box is checked

1 solution

.cs site

ChkCapacity.Attributes.Add("OnClick", "EnableDisableControl(this,'" & ChkCapacity.ClientID & "','" & DDLCapacityKgs.ClientID & "')")

function EnableDisableControl(source, Chk, ddl) {
    if (source.checked == false) {
        document.getElementById(ddl).selectedIndex = 0;
        document.getElementById(, ddl)).disabled = !source.checked;
    else {
        document.getElementById(, ddl)).disabled = !source.checked;
Share this answer
ntitish 24-May-13 1:43am    
sir actually i am posting one code can u say is it right or not

<script type="text/javascript">
function InitValidators()
Boolean chkbox=document.getElementById('<%=chkbox%>');
var ddl1=document.getElementById('<%=ddl1%>')
var ddl2=document.getElementById('<%=ddl2%>')
if(chk.checked=='true' && (ddl1.text =='' || ddl2.text ==''))
ValidatorEnable(document.getElementById('<%= RequiredFieldValidator1.ClientID%>'), true);
ValidatorEnable(document.getElementById('<%=RequiredFieldValidator2.ClientID%>'), true);
ValidatorEnable(document.getElementById('<%= RequiredFieldValidator1.ClientID%>'), false);
ValidatorEnable(document.getElementById('<%=RequiredFieldValidator2.ClientID%>'), false);
ntitish 24-May-13 1:49am    
Actually two dropdowns are in one panel which is in form and above the panel there is one checkbox if check the check box i am displaying the panel and if i uncheck the check box i am hiding the i want to give required field validators to that dropdown lists when i check the check box if i uncheck the check box the validation should be it possible

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