views:

24

answers:

1

Exact duplicate of How to select elements like question1, question2, question3,… in JQuery form validation plug-in?

<input type="text" name="question1" />
<input type="text" name="question2" />
<input type="text" name="question3" />
<input type="text" name="question4" />

$(document).ready(function() {
    $("#item").validate({
        rules: {
            title: {
                required: true,
                minlength:40
            },
         ???: {
                required: true,
                minlength:40
            },
            content: {
                required: true,
                minlength:100,
                maxlength:2000
            }
        },
        messages: {
        }
    });
});

$(":input[name^=question]") and `$(":input.question")` are used in Jquery general, not in Jquery form validation plug-in.
+1  A: 
$('#form').validate({
    rules:{
        "question1":{requred:true}
    }
    messages: {
        "question1":{requred:true}
    }
})
Funky Dude
but there are "question2", "question3", "question4",...
Steven
well that's a problem. if only rules and messages are objects then you could just add to rules or message in the same exact fashion.
Funky Dude