Try this workaround - update validator.settings.messages[element.name] with the appropiate value inside your validation method:
$.validator.addMethod("dynamic_check", function(value, element, param) { if(incorrect(value, param)){ this.settings.messages[element.name] = "some dynamic message" + dynamicValue; return false; } }, "whatever")); On Sun, Jan 25, 2009 at 10:33 PM, thomas <thomas.bik...@gmail.com> wrote: > > Thanks Jörn, > > but is there a way to change param dynamically during JS runtime? > > As example in your custom-methods-demo.html I'd like 11 to be a > function of value ... > math: {equal: 11} > > In my barcoding example, I'd like not only tell user that barcode > number is wrong, but also what the check digit should be for what he > has typed. In order to pass it into template "Entered number is wrong > the check digit must be {0}" I need to be able to alter param > somehow ... > > Regards, > Thomas > > > On Jan 25, 2:29 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com> > wrote: >> You can use $.format to create dynamic messages, but that works only >> when the dynamic part is specified as a parameter. >> >> $.validator.addMethod("dynamic_check", function(value, element, param) { >> if(incorrect(value, param)){ >> return false;} >> >> }, $.format('dynamic message goes here with param {0}')); >> >> Jörn >> >> On Sat, Jan 24, 2009 at 10:54 AM, thomas <thomas.bik...@gmail.com> wrote: >> >> > Hello group! >> >> > Very happy to have deployed validation plugin ( I mostly need to check >> > validity of EAN/UPC numbers for barcode generation). You can see it in >> > action here:http://www.barcoderobot.com/ean-13.html >> >> > The question I am struggling with though is howto return a >> > 'dynamically generated' message. Say, '13 digits are required, you >> > have XX'? >> >> > $.validator.addMethod("dynamic_check", function(value) { >> > if(_value is incorrect_){ >> > return False;} >> > }, 'dynamic message goes here');