Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Issue with validation of hidden editors.

I have a form in which there are two sections.

There are three possibilities for how it is displayed and they are:

  1. Section1 Visible, Section 2 Hidden
  2. Section 1 Visible, Section 2 Visible
  3. Section 1 Hidden, Section 2 Visible

There are editors in both sections that have the following settings:

.ValidatorOptions(m => m.OnSubmit(true).KeepFocus(ValidatorKeepFocus.Never).FormSubmit(true))

The issue is that they shouldn't be validated if they are hidden. However, I'm seeing that the hidden fields ARE showing the red "This field is required" message when the form is submitted. It shows up in the very top left corner of the screen and isn't associated with any field visible on the screen.

I am using:

  • DatePicker
  • TextEditor
  • CurrencyEditor

The current required message is from a textEditor item.

How can I set the editors to ignore the "Required" flag when hidden on the form?


FYI, I am hiding the section with jquery, similar to this:

<script type="text/javascript">
    $(document).ready(function () {
        var condition1 = @Model.ID1;
        var condition2 = @Model.ID2;

        if condition1 == 0) {
        if condition2 == 0){