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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:12:29+00:00 2026-05-13T14:12:29+00:00

Gentlepeeps, I’m new with Jquery. Apologies in advance for the basic question. I’m trying

  • 0

Gentlepeeps,

I’m new with Jquery. Apologies in advance for the basic question.

I’m trying to bring in Jquery to our struts/jsp environment. Existing code is riddled with pure javascript.

I’m writing a validation rule using JQuery’s validation plugin like so:

$("#advanceValidateform").validate({ 
 rules: { 
  advanceAmt1: { min: 0, max: 23 },
  advanceAmt2: { min: 0, max: 24 },
  advanceAmt3: { min: 0, max: 26 }
  }

});

The problem is:

  1. The values for max, min cannot be hard-coded but has to come from my action class (probably from the request). I usually do this by calling parameters in my jscript function (scriplet code passing the exact values).
  2. advanceAmt1, 2 and 3 come from a loop

A solution would be to parameterize the whole thing, have a validation rule for advanceAmt with parameters min, max and call that for each input element containing the “class” .advanceAmt .

essentially I require the jquery validation to :

  1. run on all elements with a “class” say .advanceAmt
  2. and pick up the parameters min, max from the input tag itself,(from scriplet i can generate a min=<%=x%> and max=<%=y%> )

But i’m a little lost how to do the same with jquery. Is this possible? If not any suggestions or better alternatives?

Thanks in advance.
K

  • 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-13T14:12:29+00:00Added an answer on May 13, 2026 at 2:12 pm

    On your JSP page you can use a JSTL iterator to go through the collection of validation rules and generate each one. This does not affect the javascript code because the JSTL evaluates on the server and the resulting JavaScript evaluates on the client.

    For example, suppose you have a collection of validation rules called validations that was created by your action.

      $("#advanceValidateform").validate({ 
        rules: { 
          <c:forEach var="v" items="${validations}" varStatus="loop">
             advanceAmt${v.id}: { min: ${v.min}, max: ${v.max} }${!loop.last ? ',' : ''}
          </c:forEach>  
        }
      });
    

    Some assumptions – Your collection of validation rules contain three properties id, min and max. The if statement was necessary to add a comma between the rules but not after the last one.

    Hope this helps a bit.

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

Sidebar

Related Questions

No related questions found

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.