1
场
密码: jQuery验证
OpenID登录:
有无OpenID登录:
我想验证使用jQuery这种形式。我希望在复选框被选中的情况下,密码应该被验证,如果没有选中 - openid应该被验证。我试过这个:
$().ready(
function()
{
$("#account").validate
(
{
errorLabelContainer: $("ul", $('div.error-container')),
wrapper: 'li',
rules:
{
Password:
{
required: true,
minlength: 6,
maxlength: 20
},
OpenID:
{
required: true,
minlength: 6
}
},
messages:
{
Password:
{
required: "Enter password.",
minlength: "Min length is 6.",
maxlength: "Max length is 20."
},
OpenID:
{
required: "Enter open id.",
minlength: "Min length is 6"
}
}
}
)
}
);
此代码没有考虑复选框是否被选中。我知道
函数http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-callback可以应用于requiered规则,但它符合所需的规则。我如何设法验证表单?