Add validation method to "jquery validation plugin"
<p>Hello im using jquery validation plugin to validate my form.
I want to add one more rule to the validation, but cant get it to work.
<strong>Input value should be less or equal previous element value.</strong></p>

<p>It is possible to do it ?</p>

<p>Here is the code -</p>

<pre><code>&lt;input type='text' value='&lt;?php echo $count; ?&gt;' class='input_in_stock' readonly="readonly" /&gt;
&lt;input type='text' name='amount[]' id='&lt;?php echo rand(0,99).$id; ?&gt;' size='1' value='&lt;?php echo $count; ?&gt;' class='required input_count' /&gt;

$(document).ready(function(){

    $.validator.addMethod('positiveint', function (value) { 
        return (value &gt; 0) &amp;&amp; (value != 0) &amp;&amp; (value == parseInt(value, 10));
    }, 'Enter a positive integer value.');

    $.validator.addMethod('notmorethan', function (value) { 
        return (value &lt;= $(this).prev().val());
    }, 'abc.');




    $("#cartform").validate({
        rules: {
            "amount[]": {
                required: true,
                positiveint: true,
                notmorethan: true
            }
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.next());
        }
    });

});
</code></pre>

<p>p.s. I used this jquery validation plugin fix to make it work with names like this[]
<a href="http://www.codeboss.in/web-funda/2009/05/27/jquery-validation-for-array-of-input-elements" rel="nofollow">http://www.codeboss.in/web-funda/2009/05/27/jquery-validation-for-array-of-input-elements</a></p>

<p>EDIT: found the solution</p>

<pre><code>$.validator.addMethod('notmorethan', function (value, element) { 
    return (value &lt;= $(element).prev().val() );
}, 'abc');
</code></pre>
