---
title: "How to enable and disable Required Validation group for fields and Expressions fields when a div is shown"  
description: "How to enable and disable Required Validation group for fields and Expressions fields when a div is shown"  
author: "Anonymous User"  
published: 2014-08-31  
updated: 2014-09-01  
canonical: https://www.mindstick.com/forum/2210/how-to-enable-and-disable-required-validation-group-for-fields-and-expressions-fields-when-a-div-is-shown  
category: "c#"  
tags: ["c#", ".net", "enable and disable Required Validation group", "required field validation", "open source"]  
reading_time: 1 minute  

---

# How to enable and disable Required Validation group for fields and Expressions fields when a div is shown

I have a [credit card](https://www.mindstick.com/articles/23592/how-can-you-earn-maximum-reward-points-on-credit-cards) [transaction](https://www.mindstick.com/blog/175/transactions-in-database) area in my form that I hide and show based on user's [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) in an [radio button](https://www.mindstick.com/articles/12743/radio-button-in-android) group.

With my credit card piece are [required](https://www.mindstick.com/forum/160269/what-is-required-data-annotation-how-does-it-affect-model-validation) validations and required [expressions](https://www.mindstick.com/forum/33876/what-is-the-syntax-for-lambda-expressions-in-vb-dot-net) that is in a [validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) group.

I was wondering if I could get some help with [enabling](https://yourviews.mindstick.com/view/86018/ai-and-5g-enabling-the-internet-of-things-iot) and disabling this validation group in JQuery.

Thanks in advance.

## Replies

### Reply by Sumit Kesarwani

I usually have a class that indicates whether a field should be validated or not, so when a field that should be validated is hidden, just remove the class. Add it again when it is displayed.

A more elegant solution is to disable validation of hidden fields:

$('myform').submit(function() {

$('myform').find('validate:visible').forEach( ... );

});


---

Original Source: https://www.mindstick.com/forum/2210/how-to-enable-and-disable-required-validation-group-for-fields-and-expressions-fields-when-a-div-is-shown

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
