0

This is a truly embarrasssing question. I am having a validate script problem and I have no idea why. Firebug tells me jquery is loaded, validation.js is loaded, Jquery UI is loaded and all is well. The script is on a included js page and is loaded.(does the same thing if the script in on the php file or included. Jquery 1.6.4

The error I get from firebug is: missing } after property list post:{

The } is obviously there. I can find nothing ebfore it or after that would cause this problem. The script looks picture perfect to me.

$(function(){             
  $("#postform").validate({
    rules: {
        title:{
            required: true,
            minlength: 8,
            maxlength: 200
        }
        post:{
            required: true,
            minlength: 35
        }
        category: {
            required: true
        }

        date:{
            date: true,
            required: true
        }
        author: {
            required: true,
            minlength: 6,   
            maxlength: 35
        }
    },          
    messages:{
        title:{
            required: "Required input",
            minlength: jQuery.format("At least {8} characters are necessary"),
            maxlength: jQuery.format("No more than {200} characters")
        }
        post:{
            required: "Required input",
            minlength: jQuery.format("At least {35} characters are necessary")
        }
        category: "Please choose a value from the dropdown",

        date: "A date is required",

        author: {
            required: "this field is required",
            maxlength: jQuery.format("No more than {36} characters"),
            minlength: jQuery.format("At least {5} characters are necessary")
        }

    }
});        
});

I am using ajax to process the form but it seems to me validate comes first so that shouldn't matter. I know that works.

I will also say, that I had a different set up before this (add rules on each name), the form would validate but still post to the DB even with invalid fields invalid.

Any thoughts? I have been on this for 2 days. Hopefully someone has seen this before

2 Answers 2

1

fix like this example:

   title:{
        required: true,
        minlength: 8,
        maxlength: 200
    }***,***
    post:{
        required: true,
        minlength: 35
    }
Sign up to request clarification or add additional context in comments.

2 Comments

Thats the strange part. I added the comma's all the way down to date, then it goes right back to the same original error :( when I added the comma to title as you noted, the error moved down to category. I did remove the comma's that you removed as well
did you also added comma to the "messages" section? (title{},post{},category{})
1

You are missing a bunch of commas , exactly as follows....

  $("#postform").validate({
    rules: {
        title:{
            required: true,
            minlength: 8,
            maxlength: 200
        },
        post:{
            required: true,
            minlength: 35
        },
        category: {
            required: true
        },

        date:{
            date: true,
            required: true
        },
        author: {
            required: true,
            minlength: 6,   
            maxlength: 35
        }
    },          
    messages:{
        title:{
            required: "Required input",
            minlength: jQuery.format("At least {8} characters are necessary"),
            maxlength: jQuery.format("No more than {200} characters")
        },
        post:{
            required: "Required input",
            minlength: jQuery.format("At least {35} characters are necessary")
        },
        category: "Please choose a value from the dropdown",

        date: "A date is required",

        author: {
            required: "this field is required",
            maxlength: jQuery.format("No more than {36} characters"),
            minlength: jQuery.format("At least {5} characters are necessary")
        }
    }
  });   

4 Comments

That fixed it. Thanks to both of you. Sparky I hope you don't mind if I give this to alon. Both of you were correct and alon has the lower number
Now for the real funny part. Even though there are no errors, the form does not validate, it posts through ajax and straight to the DB with empty fields. I will figure it out. I do notice up in the form opening tag it says "novalidate="novalidate""
@Brad, post a new question for your new validate problem. Maybe I can help... I've been messing with this plugin all week. BTW: you should be selecting the "best" answer for the benefit of future readers, not by who has the lowest rep. After all, I took the time to format your entire code block to eliminate possible confusion over where the issue lies.
Actually since I went to Jquery 1.6.3 none of my validations have worked. Localhost, on web codeigniter sites, all stopped working when they had worked before. I am totally unsure of how to phrase the question covering so many forms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.