Title: Enable requiredfield validator based on a dropdown value
Tags: javascript;asp.net;webforms;requiredfieldvalidator
Question: I have a dropdown and two user controls in an .aspx page where the requiredfield validation for these two user controls is controlled by the dropdown value.
For Eg: if the dropdown value is "YES" I need to enable the Requiredfield validation for these two user controls, if drop down value is "NO", I need to disable these two fields and disable the validation control as well on these two.
I am not sure how to enable/disable the required field validator from Javascript/jquery in ASP.Net Webforms application.


Here is another answer: you can have two elements. one with required attribute and one without required attribute.
based on the value of your drop down append the proper element to your container.
if(value){
$( "#container" ).append( "<input type='text' required&gt;" );
else $( "#container" ).append( "<input type='text'&gt;" );

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:12/12/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><asp.net><webforms><requiredfieldvalidator>', 'Title': 'Enable requiredfield validator based on a dropdown value', 'ViewCount': 38, 'id': 53752994, 'user_AboutMe': None, 'user_AccountId': 5749058.0, 'user_DisplayName': 'Programmerzzz', 'user_Reputation': 1109.0, 'user_Views': 253.0, 'user_id': 4539385.0}}