user2234992
user2234992

Reputation: 575

simple jquery synax seems fine, but shows error

After searching the google and SA, I decided to post this question here. I have tried all solutions I saw. I checked the braces and commas. If anyone could guide where is that am wrong, here is my jQuery

$(document).ready(function(){
    $("#form1").validate({
                debug: false,
                rules: {
                    passwordid:"required",
                    username:"required",
                    password_again :"required",
                    password_again:{
                        equalTo: "#passwordid"
                    },
                    email: {
                        required: true,
                        email: true
                    }
                },
                messages: {
                    email: "Please enter your valid email address.",
                    username: "Please enter your username",
                    passwordid:"Enter Password",
                    password_again:"Please enter the same value",
                },
                submitHandler: function(form) {
                    $.ajax
                        ({
                            type: "POST",
                            url: "new.php",
                            data: dataString,
                            cache: false,
                            success: function(html)
                            {
                                $("#result").html(html);
                            }
                        });
                });//error shown here:missing} after property list
            }
    });

Upvotes: 1

Views: 34

Answers (1)

Daniel Imms
Daniel Imms

Reputation: 50229

You have the braces wrong, try this. I swapped the second last line (}) with the third last line around (});).

$(document).ready(function () {
    $("#form1").validate({
        debug: false,
        rules: {

            passwordid: "required",
            username: "required",
            password_again: "required",
            password_again: {
                equalTo: "#passwordid"
            },
            email: {
                required: true,
                email: true
            }
        },
        messages: {

            email: "Please enter your valid email address.",
            username: "Please enter your username",
            passwordid: "Enter Password",
            password_again: "Please enter the same value",
        },
        submitHandler: function (form) {

            $.ajax({
                type: "POST",
                url: "new.php",
                data: dataString,
                cache: false,
                success: function (html) {
                    $("#result").html(html);
                }
            });
        }
    });
});

Upvotes: 1

Related Questions