views:

51

answers:

1

I copied this code and changed the final line "You must the fill in this field." from just "" (blank). The code worked in fine before (in the example) but now I get the error 'missing : after property id' on line one in this case. I checked to see if there was any vars I had missed or anything like that but no. Strange could really do with some help. I am using a jQuery plugin by the way.

I added more code as requested but I don't really think theres anything else I can add. I am using a plugin lib that I thought would be doing the rest. See documentation here.

    // a custom method making the default value for item and description invalid.
  jQuery.validator.addMethod("defaultInvalid", function(value, element) {
        return value != element.defaultValue;
    }, "You must the fill in this field.");

   rules: {
     item: {
       minlength: 3
     },
     desciption: {
       required: true,
       minlength: 3
     },
     city: {....................
A: 

OK, my mistake. I had written the function after the form validate which is apparently incorrect. I had to play around to find this out. The online documentation didn't explain this. Code should be like the following:

     // a custom method making the default value for item and description invalid.
  jQuery.validator.addMethod("defaultInvalid", function(value, element) { 
        return value != element.defaultValue;
    }, "You must the fill in this field.");

$("#l_form").validate({

   rules: {
     item: {
       minlength: 3
     },
     desciption: {
       required: true,
       minlength: 3
     },....................
Cool Hand Luke UK