如何在JQuery表单验证插件中选择问题1,问题2,问题3,...等元素?

时间:2009-11-16 04:43:29

标签: jquery plugins validation

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 个答案:

答案 0 :(得分:1)

$('#form').validate({
    rules:{
        "question1":{requred:true}
    }
    messages: {
        "question1":{requred:true}
    }
})