Click here to Skip to main content
15,896,421 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Summary: For some reason, the parameters getting passed to the callback function of jQuery.validator.addMethod is
JavaScript
NaN
. I can't understand why as when adding the rule to the adapters, everything is getting passed correctly. I'm using the jQuery Validation Plugin 1.8.0 and testing on FF 3.5.3.

Thanks for any help!

Additional Details: Within the jQuery.validator.addMethod's callback method, the params parameter always is NaN instead of object. Am I missing something here?

Here's the relevant jquery code:

JavaScript
jQuery.validator.unobtrusive.adapters.add('myrule', ['p1', 'p2'], function (options) {
options.rules['myrule'] = { p1: options.params.p1, p2: options.params.p2};
...
});

 jQuery.validator.addMethod('myrule', function (value, element, params) {
//business logic here.

//value of params is NaN. I debugged within the jquery.validate.js- var rule = { method: method, parameters: rules[method] };  rules[method] is NaN

}, '');
Posted

1 solution

The reason was that I had actually used one of the keywords viz. 'minlength' (which I had masked above as 'myrule' when I posted my question above. Changing the name of the rule from 'minlength' to something else resolved the issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900