开发者

missing : after property id code was copied from a working example?

开发者 https://www.devze.com 2022-12-29 01:58 出处:网络
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 \'miss

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: {....................


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
     },....................
0

精彩评论

暂无评论...
验证码 换一张
取 消