开发者

jQuery validate, can't get it to work

开发者 https://www.devze.com 2022-12-15 17:00 出处:网络
OK, beating my head against the Javascript/jQuery wall over here, here is the code, which I simply can\'t get to work properly, any help is highly appreciated!

OK, beating my head against the Javascript/jQuery wall over here, here is the code, which I simply can't get to work properly, any help is highly appreciated!

Especially this bugs me, changing row 60 from

c.gbForm.validator = c.dom.gbForm.validate(c.gbForm.validator); to

c.gbForm.validator = $("#gbForm").validate(c.gbForm.validator);

and row 61 from

c.dom.gbForm.unbind('submit').submit(c.gbForm.doAdd); to

$("#gbForm").unbind('submit').submit(c.gbForm.doAdd);

makes it kinda work, except then I get this[0] is undefined error which I think is the jQuery validate plugin but I simply can't locate the exact spot at开发者_开发技巧 fault... So any hints/pointers to why the whole "var c" business isn't working and the same for the "this[0]" part would be awesome!

Thanks for any assistance!

John


Yes, here are a few things to look at

c.gbForm.validator = $("#gbForm").validate(c.gbForm.validator);

here you are referencing c.gbForm.validator before it is set (assuming this is the first assignment to c.gbForm.validator).

try this.

c.gbForm.validator = $("#gbForm");
c.gbForm.validator = $("#gbForm").validate(c.gbForm.validator);

also, why do you call c.doc.gbForm in one spot and just c.gbForm in another?

and as the comment says, validation should be as simple as $("gbForm").validate();

0

精彩评论

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