Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8356261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:08:11+00:00 2026-06-09T10:08:11+00:00

I have a form that has an option to enter dimensions for: Width &

  • 0

I have a form that has an option to enter dimensions for:

  • Width & Height
  • Width
  • Height

And I have two container divs that I hide/show depending on which of the three options is selected:

<div class="editor-field" id="width-container">
     @Html.EditorFor(model => model.Width)
     @Html.ValidationMessageFor(model => model.Width)
</div>

<div class="editor-field" id="height-container">
     @Html.EditorFor(model => model.Height)
     @Html.ValidationMessageFor(model => model.Height)
</div>

If height is selected, then width is not displayed on the form, how can I disable the unobtrusive validation on the Width input field in a fashion that will allow me to easily re-instate it if the user changes their mind i.e. removing data-* attributes is not an option. I’m happy to create an CustomAttribute class to handle this BUT I do not want to have to hack the standard jquery files to make this work as it makes updating to new versions a headache down the track. If all else fails I’ll use my usual trick of adding a value of 0 to the fields when they are not visible and then removing it when they are shown.

EDIT:

Please be mindful that when Width is not visible it is not a “hidden” field per se it’s just a input tag that’s not visible to the user because the parent div has a style of display:none

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:08:12+00:00Added an answer on June 9, 2026 at 10:08 am

    You can set up the jQuery validator that’s processing your unobtrusive validation to ignore hidden elements:

    jQuery.validator.defaults.ignore = ":hidden";
    
    // the line above is outside any $(document).ready(...) or similar
    $(document).ready(function(){
        ...
    });
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that has two select lists: <select name=rating1 id=rating1> <option>1</option> <option>2</option>
I have a form that has a group of 3 text_fields. I need two
I have a form that has two buttons on it, one yes, one no,
I have a simple PHP script with a form that has two select fields,
i have a form that has select element <select name=adddisplaypage[] id=adddisplaypage multiple=multiple> <option value=all
I have a form that has a select menu(A) and 2 divs (B and
I have one form that has an option to open another (dialogue). I want
I have a form that has label values that I would like to pass
I have a form that has many long-methods. My quest is: What is the
I have a form that has 8 columns and a variable number of rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.