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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:43:36+00:00 2026-06-17T19:43:36+00:00

I have these validation rules: $(#ed_details).validate({ rules: { tagno: { required: true }, itemid:

  • 0

I have these validation rules:

$("#ed_details").validate({
    rules: {
        tagno: { required: true },
        itemid: { required: true },
        ralno: { required: true },
        feet: { required: true, number: true, min: 0 },
        inches: { required: true, number: true, min: 0 },
        cms: { required: true, number: true, min: 0 },
        length: { required: true, number: true, max: $('#maxlength').val() },
        qty: { required: true }
    }
});

This is the field that lengths validates against. It is text only for testing purposes. It will be hidden once this is working.

<input type="text" name="maxlength" id="maxlength" value="<?=$maxL['ml']?>" />

This works fine unless I change the value of maxlength at runtime (which can happen). The user is selecting an item from a drop down. Each item has a maximum length of tubing that can be used with it. When the item changes, the value of maxlength does change on the screen. However, when the validation runs, I see an error message based on the original length (0 for a new item, whatever the maxlength was at load for an edit).

Please enter a value less than or equal to 156.

I see this even when the maxlength field shows another value.

If I use Firebug on the field, it shows the original value even after it has been changed. Also, changing the maxlength field by hand instead of code does not make a difference.

Any help is greatly appreciated.

  • 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-17T19:43:38+00:00Added an answer on June 17, 2026 at 7:43 pm

    You can not change rules like this…

    length: { 
        required: true,
        number: true, 
        max: $('#maxlength').val()
    },
    

    That’s because, like most jQuery plugins, .validate() is called only one time to initialize the plugin on your form… it does not run repeatedly, so dynamically changing the rules options within .validate() does nothing.

    Use the rules method to add and update your rules dynamically. (use along with the code that changes the value.)

    $('#maxlength').rules("add", {
         max: $('#maxlength').val()
    });
    

    See this very crude “proof of concept” demo below (room for you to rearrange). Test the form (value is initially 5). Then click the button one time and the value and rule (along with message) are updated correctly to “2”.

    http://jsfiddle.net/Y565M/

    http://docs.jquery.com/Plugins/Validation/rules#.22add.22rules

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

Sidebar

Related Questions

I have these three lists with the same number of elements List<String>competitoinsIDs = new
I have a few custom form validation rules I wish to apply. Things like
I have a form with a few entry fields that have validation rules. Next
In the current version of Salesforce, IF I have multiple Validation Rules Error message
I have a custom jQuery validate rule called fiftyCents() where there are two rules:
Hopefully a simple one. I have the following form validation rules: $this->form_validation->set_rules('timeStart', 'Day Start
I'm designing a database to hold my domain objects. I have various validation rules
How would I add validation rules to my columns after Models have been generated.
I have text input boxes. There is validation for each of the boxes using
I have a small jQuery plugin that I use for form AJAX validation. There

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.