动态地将参数传递给jQuery验证函数

时间:2013-01-02 06:06:52

标签: jquery

我想动态地为email_i分配值.......

var v = $("#email_address").validate({  
        rules: { activation_code: {
                required: true,
                alphanumeric: true,
                remote: "mail.php?action=activation_code&email="+**email_i**
            }
        }, 
messages: { 
activation_code: {
                required:       "Please input your activation code.", 
                alphanumeric:   "Only latin characters, numbers and _ sign are allowed.",
                remote:         "Sorry, activation code is incorrect."
            }
        }, 
success: function(label) {
            label.addClass( "formSuccess" );
            label.html('<img src="HelpOneAnother/giveNet/themes/givearang_1001/gfx/icons/ok.gif" border="0" \>') ;
}
});

1 个答案:

答案 0 :(得分:0)

根据文档使用rules('add')方法:

http://docs.jquery.com/Plugins/Validation/rules#.22add.22rules

$('#emailFieldID').rules('add',{

   ruleIwantForEmail: true
})