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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:53:56+00:00 2026-06-10T07:53:56+00:00

My form has several rather complex validation rules and it became necessary for me

  • 0

My form has several rather complex validation rules and it became necessary for me to temporarily disable a given rule only to enable it later. It seemed pointless having to remove it and then add it again later so I needed a facility to disable and enable validation rules.

  • 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-10T07:53:58+00:00Added an answer on June 10, 2026 at 7:53 am

    Starting with jquery.validate.js from version 1.8.1 I added in 2 case statments to the “rules” function so that the command switch statement reads as follows.

    switch(command) {
    case "add":
        $.extend(existingRules, $.validator.normalizeRule(argument));
        staticRules[element.name] = existingRules;
        if (argument.messages)
            settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
        break;
    case "remove":
        if (!argument) {
            delete staticRules[element.name];
            return existingRules;
        }
        var filtered = {};
        $.each(argument.split(/\s/), function(index, method) {
            filtered[method] = existingRules[method];
            delete existingRules[method];
        });
        return filtered;
    case "disable":
        if (!argument) {
            return false;
        }
        $.each(argument.split(/\s/), function(index, method) {
            existingRules[method].disabled=true;
        });
        break;
    case "enable":
        if (!argument) {
            return false;
        }
        $.each(argument.split(/\s/), function(index, method) {
            existingRules[method].disabled=false;
        });
        break;
    }
    

    Then to implement this, in the “check” function we add a conditional to check the state of this disabled parameter we have set. Notably, if the rule has never been disabled/enabled then the value will be undefined, we assume here that if its undefined we’re happy with the rule. The loop statement for this function now starts with:

    for (var method in rules ) {
        var rule = { method: method, parameters: rules[method] };
        try {
            if (typeof rule.parameters["disabled"] === 'undefined' || rule.parameters["disabled"] == false)
            {
                var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
            } else {
                continue;
            }
    

    Use this just as you would the “add” and “remove” facilty, e.g.

    $('#email_address').rules("disable", "remote");
    $('#email_address').rules("enable", "remote");
    

    I hope this helps someone, I’ve been bashing my head against the wall trying to get to here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms app and the main (and only) form has several buttons.
my form has several submit buttons, and the validation of some of the fields
My form has several numeric up down controls. All of these controls, when changed,
I have a page that has several ajax submission forms. Each form has a
I'm working on a long form that has several radio button groups. At the
I'm constructing a Form and it has several numericUpDown controls, several checkbox controls and
My android application has several warnings of the following form when I run it
the user has the option of dragging several pictureboxes around the form. when he
My form has several buttons such as Scan and Exit. I have seen in
I have a form that has several controls: ProgressBar at the top of the

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.