[jQuery] Re: [validate] dynamic message

2009-02-08 Thread himanshu
Hi, I am trying to validate an optional field but it is validated every time either it is included or not on the form.Please help me that how can i validate optional fields using jQuery validator. Regards, Himanshu Singh On Jan 26, 3:18 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com wrote:

[jQuery] Re: [validate] dynamic message

2009-01-30 Thread thomas
Jörn, many thanks - this has worked wonderfully! The only remaining question I have is as follows: messages generated by specified validation methods clear automatically after the form field gets updated: so in the chain of required,digits,minlength,maxlength each message comes and goes as

[jQuery] Re: [validate] dynamic message

2009-01-30 Thread Jörn Zaefferer
Ah, good question. Try this: $.validator.addMethod(dynamic_check, function(value, element, param) { if(incorrect(value, param)){ this.settings.messages[element.name].dynamic_check = some dynamic message + dynamicValue; return false; } }, whatever)); That sets the new

[jQuery] Re: [validate] dynamic message

2009-01-26 Thread Jörn Zaefferer
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

[jQuery] Re: [validate] dynamic message

2009-01-25 Thread Jörn Zaefferer
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

[jQuery] Re: [validate] dynamic message

2009-01-25 Thread thomas
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