0

我有一个使用 jQuery Validate 的验证函数,它当前给了我错误:

未捕获的 SyntaxError:意外的数字

然而,我似乎无法找出我的代码到底出了什么问题。我尝试通过将它们注释掉来删除有问题的行,但我得到的只是另一个错误

未捕获的 SyntaxError:意外的标识符

我的代码:

<script type="text/javascript">
    $(document).ready(function(){
        $.extend($.validator.messages,{
            equalTo: "Your passwords do not match.",
            remote: "The password you entered is incorrect."
        });

        $('#PasswordChange').validate(function() {
            rules: {
                ChangePassNew: {
                    required: true,
                    minlength: 6 //<-- the line giving the error.
                },
                ChangePassConfirmNew: { //<-- the line giving the new error once the offending line is commented out
                    required: true,
                    minlength: 6
                },
                ChangePassConfirmOld:{
                    required: true,
                    minlength: 6,
                    remote: "verifypass.php"
                },
                messages: {
                    ChangePassNew: {
                        required:"Please enter a password.",
                        minlength:"Please enter at least 6 characters."
                    },
                    ChangePassConfirmNew: {
                        required:"Please enter a password.",
                        minlength:"Please enter at least 6 characters."
                    },
                    ChangePassConfirmOld: {
                        required:"Please enter a password.",
                        minlength:"Please enter at least 6 characters.",
                        remote:"The password you entered is incorrect."
                    },
                },
            },
            submitHandler:function(form){
                form.submit();
            }
        });
    });
</script>

任何帮助,将不胜感激。

4

1 回答 1

2

改变

$('#PasswordChange').validate(function(){

$('#PasswordChange').validate({

您需要一个包含选项的对象,而不是一个函数。

于 2013-11-11T13:03:50.820 回答