Jörn Zaefferer wrote:
>
> Randall J. Parr schrieb:
>> [...]
>> All of the above selectors seem to work when tested in firebug; that 
>> is, the proper line items (forms) are found.
>>
>> 1) Is it possible to validate one or more forms in a given page based 
>> on something other than id?
>>
>> 2) If yes, what (probably simple thing) am I missing in the above?
>>
>> 3) If no, is it possible using a different approach such as adding a 
>> button (instead of a form), detecting when any button of a given 
>> class/type is clicked, and programatically performing the validation 
>> and the submission?
>>   
> There is currently a limitation in place that lets you validate only 
> one form per call to validate. So to evoid writing the call more then 
> once you have to write a loop:
>
> $(".selector").each(function() {
>  $(this).validate(...);
> });
>
> I'm aware of the problem but won't be able to fix it until the 2.0 
> release due to backwards compability.
>
> Please let me know if you've got any other issues.
>
> Regards
> Jörn

That worked nicely.

$().ready( function()
{
    $("form.BUYITBELOW:has([name='itemquant'][type='text'])").each( 
function()
    {
         $(this).validate(
        {
            rules: {
                itemquant:
                {
                    required: true,
                    digits: true,
                    minLength: 2
                }
            },
            messages:
            {
                itemquant:
                {
                    required: "Please enter a qty",
                    digits: "Qty must be a number",
                    minLength: "Qty must be at least 2 digits"
                }
            }
        });
    });    
});


Thanks.
R.Parr

Reply via email to