I have an ASP.Net Core project with a simple form that has two radio buttons. One radio button has a drop-down and the other has a text-box. If the user selects the first radio button, I would like to remove/ignore the validation for the text-box (since its empty) when the user press the submit button. Vice versa, if the user selects the second option, I would like to remove/ignore the validation from the drop-down. I have tried a bunch of jQuery methods found on StackOverflow but none have work.
Model:
public class EnrollmentModel : BaseModel
{
...
public bool PriceOption { get; set; }
[Required(ErrorMessage = "Please select a rate plan")]
public string SelectedRatePlan { get; set; }
public IEnumerable RatePlans { get; set; }
[Required]
public string CustomRate { get; set; }
...
}
}
View:
Screenshot:
What is rendered:
div class="form-group">
I came across something about implementing a custom validator derived from ValidationAttribute, IClientModelValidator or is there easier method to achieve what I want? Thank you.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)