Try this:
var rule = {
required: true,
range:[0,100]
};
var rules = {};
$(".numOnly input").each(function() {
rules[this.name] = rule;
});
$(".numOnly").validate({ rules: rules });
Jörn
On Wed, Oct 8, 2008 at 7:08 PM, Syler <[EMAIL PROTECTED]> wrote:
>
> i have a form and a bunch of inputs.
>
> How do i make it so that all my input apply the same validation rule
> without having to put in the name attr. in the rules?
>
> so I have class="numOnly" in my <input>
> this won't work,
> $(document).ready(function(){
> $(".numOnly").validate({
> rules: {
> required: true,
> range:[0,100]
> }
> });
>
> }
>
> this only works if i put in the name attr like:
>
> $(document).ready(function(){
> $(".numOnly").validate({
> rules: {
> blah: {
> required: true,
> range:[0,100]
> }
> }
> });
>
> }
>
> since my input field only require these condition i need a better way
> then having a large loop listing all the name attributes withing the
> "rules" prototype.
>