Validations
-
hi all, in my web page i have one dropdown list it contains Email and Phone values. and i hav email and phone textboxes. now the thing is if i select email from drop down list i want Email as mandatory, if i select phone from dropdown list i want Phone as mandatory! how to achieve this? i have written my code as follows! if (ddlCmethod.SelectedValue == "Telephone") { valmanEmail.IsValid = false; valmanPhone.IsValid = true; } else { valmanPhone.IsValid = false; valmanEmail.IsValid = true; }
-
hi all, in my web page i have one dropdown list it contains Email and Phone values. and i hav email and phone textboxes. now the thing is if i select email from drop down list i want Email as mandatory, if i select phone from dropdown list i want Phone as mandatory! how to achieve this? i have written my code as follows! if (ddlCmethod.SelectedValue == "Telephone") { valmanEmail.IsValid = false; valmanPhone.IsValid = true; } else { valmanPhone.IsValid = false; valmanEmail.IsValid = true; }
i think if the valmanPhone is required field validator or any validator you should not set IsValid property you need to set IsRequired property true ro false
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
i think if the valmanPhone is required field validator or any validator you should not set IsValid property you need to set IsRequired property true ro false
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
thanks for the reply :) but there is no IsRequired property.
-
thanks for the reply :) but there is no IsRequired property.
OOPs :sigh: What problem are you facing is it not firing the validation properly ?
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
thanks for the reply :) but there is no IsRequired property.
for what control u are trying to set the IsValid=false ..i.e is valmanEmail is a validator control? if so then set Enabled = false;
Koushik
-
OOPs :sigh: What problem are you facing is it not firing the validation properly ?
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
actually thing is... i want to made a field is require as per the dropdownlist item selected. means if i select Email from my dropdown list the the Email field must become mandatory and phone field will be normal means not mandatory. if i select Phone then phone filed must become mandatory and Email field will be not mandatory. how to achieve this!!! :confused:
-
for what control u are trying to set the IsValid=false ..i.e is valmanEmail is a validator control? if so then set Enabled = false;
Koushik
Thanks for reply... :) no its not working!!!! :(
-
hi all, in my web page i have one dropdown list it contains Email and Phone values. and i hav email and phone textboxes. now the thing is if i select email from drop down list i want Email as mandatory, if i select phone from dropdown list i want Phone as mandatory! how to achieve this? i have written my code as follows! if (ddlCmethod.SelectedValue == "Telephone") { valmanEmail.IsValid = false; valmanPhone.IsValid = true; } else { valmanPhone.IsValid = false; valmanEmail.IsValid = true; }
You can achive through Dropdown on click Javascript event. Based on the selected value function EnableValidator() { if(document.getElementById('<%=ddlCmethod.ClientID%>').value=='Telephone') { ValidatorEnable(document.getElementById('<%=valmanEmail.ClientID%>'), false); ValidatorEnable(document.getElementById('<%=valmanPhone.ClientID%>'), true); } else { ValidatorEnable(document.getElementById('<%=valmanEmail.ClientID%>'), true); ValidatorEnable(document.getElementById('<%=valmanPhone.ClientID%>'), false); } } Just call 'EnableValidator()' function on click of the dropdownlist This will work.
Shanmugam R
-
You can achive through Dropdown on click Javascript event. Based on the selected value function EnableValidator() { if(document.getElementById('<%=ddlCmethod.ClientID%>').value=='Telephone') { ValidatorEnable(document.getElementById('<%=valmanEmail.ClientID%>'), false); ValidatorEnable(document.getElementById('<%=valmanPhone.ClientID%>'), true); } else { ValidatorEnable(document.getElementById('<%=valmanEmail.ClientID%>'), true); ValidatorEnable(document.getElementById('<%=valmanPhone.ClientID%>'), false); } } Just call 'EnableValidator()' function on click of the dropdownlist This will work.
Shanmugam R
hey thanks for ur response! but there is no property called OnClick for dropdown list!!!
-
hey thanks for ur response! but there is no property called OnClick for dropdown list!!!
Just include the following code on server side (Form Load event). drpList.Attributes.Add("onchange", "JavaScriptFunctionName();"); or drpList.Attributes.Add("onclick", "JavaScriptFunctionName();"); We can add properties using the Attributes method.
Shanmugam R