Didnt i try that... :P. Thanks a lot for soulution and quick response!! That did a exactly what i wanted.
On 19 joulu, 22:25, Andre Polykanine <an...@oire.org> wrote: > Hello Antti and all, > > You just don't need to nestmessages, they should be > overwritten: > > inputfield_2: { // THIS IS WHAT I WOULD LIKE TO HAVE > required:"inputfield 2 required > message", > maxlength:"inputfield 2 maxlength > message", > customRule: "maybe overwrite > custom message here" > } > > -- > With best regards from Ukraine, > Andre > Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ > jabber.org > Yahoo! messenger: andre.polykanine; ICQ: 191749952 > Twitter: m_elensule > > > > ----- Original message ----- > From: Antti <antti.mak...@mindworks.fi> > To:jQuery(English) <jquery-en@googlegroups.com> > Date: Saturday, December 19, 2009, 12:09:32 PM > Subject: [jQuery]jQueryValidationPluginmessagesby field rule. > > Hi! > Im quite newbie withjquerybut so far i think it realy rocks. Anyways > im now trying to useValidationpluginbut have one problem to solve > to get in job done. > > My form has natrually many fields, each field can have many rules, > even custom rules. Trouble is that i cant find a way to overwrite > defaultmessagesby fields rule. > > For example i wanna different errormessagesfor first_field required > message and first_field minlength message. And thosemessageswould > need to be different than second_field with same rules but differentmessages. > (Dont know if nestedmessagesis right word for what i want) > > Code what i have. > > jQuery.validator.setDefaults({ > debug: true, > success: "valid", > }); > > jQuery.validator.addMethod("customRule",function (value) > { > var i; > for (i=0; i < arr.length; i++) { > if (arr[i].value == value ) { > return true; > } > } > return false; > }, "CustomRule message."); > > $(document).ready( function(){ > > var validator = $("#form").validate({ > rules: { > inputfield_1: { > required: true > }, > inputfield_2: { > required: true, > maxlength: 5, > customRule: true > } > }, > messages: { > inputfield_1: "inputfield1 message ", > inputfield_2: { // THIS IS WHAT I WOULD LIKE TO HAVE > messages: { > required:"inputfield 2 required > message", > maxlength:"inputfield 2 maxlength > message", > customRule: "maybe overwrite > custom message here" > } > } > } > }); > > Hope you understand my problem... I would be realy glad if someone > could. Thanks for advance!