How to remove required field validation based on dropdown value of another control in asp.net c#

  • Thread starter Thread starter Rama Naidu
  • Start date Start date
R

Rama Naidu

Guest
Dear All,

<li>
<div>
<label class="c_label">Training Period in Months</label>
<!--<span class="required">*</span>-->
</div>
<span dir="none">
<asp:DropDownList ID="TrainingPeriodinMonths" title="TrainingPeriodinMonths" runat="server" class="ms-RadioText">
</asp:DropDownList>
<br />
<asp:CustomValidator SetFocusOnError="true" CssClass="ValidatorStyle" ID="CustomValidatorTrainingMonths" runat="server" ErrorMessage="Please select Training in months" ClientValidationFunction="ValidateTrainingMonths"></asp:CustomValidator>
</span>
<div>
</div>
</li>

The above line of code is my control, now i would like to remove required field validation based on another dropdown value.

If user selects "volunteer hours" from training required, then training months should be enabled and if any other value except volunteer hours training months should be required.

1498370.png


Below is my code but it is not working, i am writing in usercontrol.ascx only.

function ValidateTrainingMonths(sender, args) {

jQuery("#ctl00_ctl46_g_d41ac2cc_706c_45d6_90fb_384456097658_ctl00_Whatkindoftrainingrequired_x003a").click(function () {

if (jQuery('select[title="Whatkindoftrainingrequired:"]').val() == "Volunteer hours") {
$('select[title="TrainingPeriodinMonths"]').attr('disabled', 'disabled');
}
else {
$('select[title="TrainingPeriodinMonths"]').removeAttr('disabled');
}
});
}



Ramanjjilu Naidu

Continue reading...
 
Back
Top