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:
- 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).
- 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 :
- run on all elements with a "class" say .advanceAmt
- 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