Проверка JQuery не работает - PullRequest
0 голосов
/ 21 марта 2011

Есть идеи, почему этот код не работает?

var newpost_validator = {};
var editpost_validator = {};

var newupload_validator = {};
var editupload_validator = {};

var newquestion_validator = {};
var editquestion_validator = {};

var comment_validator = {};

$(function()
{
    newpost_validator = $("#newpostform").validate({
        rules: {
            post_title: "required",
            post_url:  {
                required: {
                    depends: function() {
                        return $('input[name=post_category]:checked').val() == '14';
                    }
                },
                url: true
            },
            post_code: {
                required: {
                    depends: function() {
                        return $('input[name=post_category]:checked').val() == '13';
                    }
                }
            },
            post_content: "required",
            post_tags: "required"
        },
        messages: {
            post_title: "Your post MUST have a title",
            post_url: "Please enter a valid URL, don't forget the http://",
            post_code: "Please add your code",
            post_content: "Your post MUST have some content",
            post_tags: "Please add some tags"
        }
    });

    editpost_validator = $("#editpostform").validate({
        rules: {
            post_title: "required",
            post_content: "required"
        },
        messages: {
            post_title: "Please enter a title",
            post_content: "Please enter the content"
        }
    });

    newquestion_validator = $("#newquestionform").validate({
        rules: {
            post_title: "required",
            post_content: "required",
            post_tags: "required"
        },
        messages: {
            post_title: "Please enter a title",
            post_content: "Please enter the content",
            post_tags: "Please enter some tags"
        }
    });

    editquestion_validator = $("#editquestionform").validate({
        rules: {
            post_title: "required",
            post_content: "required"
        },                          },
        messages: {
            post_title: "Please enter a title",
            post_content: "Please enter the content"
        }
    });

    newupload_validator = $("#newuploadform").validate({
        rules: {
            post_title: "required",
            post_upload: {
                  required: true,
                  accept: "jpg|jpeg|gif|bmp|png"
                },
            post_content: "required",
            post_tags: "required"
        },
        messages: {
            post_title: "Please enter a title",
            post_upload: "Please upload a valid image file",
            post_content: "Please enter the content",
            post_tags: "Please enter some tags"
        }
    });

    editupload_validator = $("#edituploadform").validate({
        rules: {
            post_title: "required",
            post_content: "required"
        },
        messages: {
            post_title: "Please enter a title",
            post_content: "Please enter the content"
        }
    });

    comment_validator = $("#commentform").validate({
        rules: {
            comment: "required"
        },
        messages: {
            comment: "Please add a comment"
        }
    });

});

Поскольку ни одна из форм не проверяется: /

Спасибо.

1 Ответ

0 голосов
/ 21 марта 2011

Нашел ошибку :), кажется, я сделал это }, },

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...