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

  • Home
  • SEARCH
  • 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 3340882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:39:32+00:00 2026-05-18T00:39:32+00:00

Is there a way to pass dynamic parameters into a custom jquery validate method?

  • 0

Is there a way to pass dynamic parameters into a custom jquery validate method? Specifically, I was looking for a way to compare 2 controls and would like to pass one to the other’s validate method for comparison.

Here is what I currently have:

 //Add method
 $.validator.addMethod("lowerInt", function(value, element, params) {
            alert('inside method');
            if (isNaN(parseInt(params)))
                return true;
            else
                return parseInt(value) < parseInt(params);
        }, $.validator.format("Please enter a number smaller than {0}")); 

 //Set validation
 $("#form1").validate({
     rules: {
        lowInt: {
            required: true,
            integer: true,
            lowerInt: 8 //I would like to pass a dynamic value here
        }
     }
 });

If I run it as above, it works as it should. If I change the 8 passed in to lowerInt to $(‘#highInt’).val(), it seems to set the value for the lowerInt function only once and never update it. I realize that I can get the value inside of the method by calling $(‘#highInt’).val(), but I would like to pass the value instead if at all possible.

  • 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-05-18T00:39:32+00:00Added an answer on May 18, 2026 at 12:39 am

    I would pass in a selector, like this:

    //Add method
    $.validator.addMethod("lowerInt", function(value, element, params) {
      var hi = typeof params[0] == "string" ? 
               parseInt($(params[0]).val(), 10) :
               params[0];
      if (isNaN(hi))
        return true;
      else
        return parseInt(value) < hi;
    }, $.validator.format("Please enter a number smaller than {0}")); 
    
    //Set validation
    $("#form1").validate({
      rules: {
        lowInt: {
            required: true,
            integer: true,
            lowerInt: '#highInt'
        }
      }
    });
    

    This version will take either a number or a selector, making it as flexible as possible.

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

Sidebar

Related Questions

Is there a way to pass a call back function in a Java method?
Is there a way to pass null arguments to C# methods (something like null
Is there a way to pass a start time via URL when opening a
Does anybody know if there is a way using java to pass all the
How do you pass options to an executable? Is there an easier way than
Is there any way to pass a variable from the suite to the test
Is there any way to pass to deactivate: whether an element was dropped or
Is there way in next piece of code to only get the first record?
is there way thats i can preselect an item when the page loads or
Is there a way to enforce constraint checking in MSSQL only when inserting new

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.