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 8560927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:23:17+00:00 2026-06-11T16:23:17+00:00

The form has two check boxes (cbDeclined & cbIsOOfFac), two text fields and a

  • 0

The form has two check boxes (cbDeclined & cbIsOOfFac), two text fields and a drop down (txtHeight, txtWeight, ddlDevice).

If either check box is checked, then the other controls are disabled and the rules for the other do no apply. Here are the current rules:

$('form').validate({
    highlight: function (element, errorClass) {
        $(element).addClass("invalidElem");
    },
    unhighlight: function (element, errorClass) {
        $(element).removeClass("invalidElem");
    },
    errorPlacement: function (error, element) {
        var parent = element.parent();
        parent.append(error);
    },
    errorElement: "div",
    errorClass: "errorMsg"
});

function HeightWeightCtrlsEnabled() { return !cbDeclined.is(':checked') && !cbIsOOfFac.is(':checked'); }

txtHeight.rules("add", { required: function (element) { return HeightWeightCtrlsEnabled(); }, maxlength: 3, min: 1, digits: true });
txtWeight.rules("add", { required: function (element) { return HeightWeightCtrlsEnabled(); }, maxlength: 4, min: 1, digits: true });
ddlDevice.rules("add", { required: function (element) { return HeightWeightCtrlsEnabled(); } });

function UpdateTextBoxes() {
    var disableCtrls = !HeightWeightCtrlsEnabled();

    txtHeight.prop('disabled', disableCtrls);
    txtWeight.prop('disabled', disableCtrls);
    ddlDevice.prop('disabled', disableCtrls);

    if (disableCtrls) {
        txtHeight.val('');
        txtWeight.val('');
        ddlDevice.val('');
    }
}

cbDeclined.click(function () {

    if (cbDeclined.is(':checked'))
        cbIsOOfFac.attr('checked', false);

    UpdateTextBoxes();
});

cbIsOOfFac.click(function () {

    if (cbIsOOfFac.is(':checked'))
        cbDeclined.attr('checked', false);

    UpdateTextBoxes();
});

The problem comes in when: The user enters something into txtWeight, clicks the submit to get both ddlDevice & txtHeight to highlight because they are required, then… The user clicks on either cbDeclined & cbIsOOfFac. The highlight is NOT going away. I am trying to figure out how to get the highlighting around the height and drop down to go away.

I tried to create a fully working jsFiddler, but I cannot get anything to work, though everything looks correct. here is the link (I cannot post links, so I expanded it a bit)

jsfiddle dot net/scarleton/9hDZQ/12/

If you remove the last /12/, you will see my first version that is a cut/paste from the real thing.


Per a suggestion I tried adding $(‘form’).valid(); a number of places.

When I added it to the end of the UpdateTextBoxes() function, they started out highlighted, not what I want.

When I added it after the click() event of either of the radio button, the text would go away, but the actual controls stayed highlighted. It looks like the function on the required property of the rule is not fully working, maybe. What is really interesting is this: When I enter a height, click , then weight and device are highlighted and have the error message under them. When I click on one of the radio buttons, the text goes away, but the highlight does not. But… The height is NOT highlighted, it stays normal.

  • 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-11T16:23:18+00:00Added an answer on June 11, 2026 at 4:23 pm

    Working fiddle: http://jsfiddle.net/9hDZQ/15/ (lacks your highlight CSS styles, but classes are added/removed properly)

    There was no code to tell the validation plugin to re-check the form when you check one of those boxes. Adding $('form').valid(); at the bottom of each click handler to force re-validation works for me:

        cbDeclined.click(function () {
    
            if (cbDeclined.is(':checked'))
                cbIsOOfFac.attr('checked', false);
    
            UpdateTextBoxes();
            $('form').valid();
        });
    
        cbIsOOfFac.click(function () {
    
            if (cbIsOOfFac.is(':checked'))
                cbDeclined.attr('checked', false);
    
            UpdateTextBoxes();
            $('form').valid();            
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A form on my website's contact -us HTML page has two fields 1) subject
http://www.example.com?a=1&a=2 has a valid form-urlencoded querystring and has two values ( 1 and 2
I have a form in which I want two check boxes to be required
I have a form with a table that has two input boxes, a select
I have a form that has two buttons on it, one yes, one no,
I have a windows form that has two DataGridViews (DGVs) that will hold 25,000+
i want to create a form that has two submit buttons, but each one
I have a form in Axapta/Dynamics Ax (EmplTable) which has two data sources (EmplTable
I have a table inside a form. It has two columns, the first one
I have a form that has a group of 3 text_fields. I need two

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.