I am trying to implement clientside validation using the clientside validation model. I have been following the documentation located here. Specifically the Form API Section for Drupal 7. I believe I have followed the instructions faithfully but when I try it out I get the following error:
Uncaught TypeError: Cannot call method 'call' of undefined at 507 jquery.validate.js
Here is my slightly modified jquery script I am using:
(function ($) {
//Define a Drupal behaviour with a custom name
Drupal.behaviors.dynamicTextfieldValidator = {
attach: function (context, settings) {
//Add an eventlistener to the document reacting on the
//'clientsideValidationAddCustomRules' event.
$(document).bind('clientsideValidationAddCustomRules', function(event){
//Add your custom method with the 'addMethod' function of jQuery.validator
//http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage
jQuery.validator.addMethod("validInputType", function(value, element, param) {
return value !== '';
}, jQuery.format('Field can not be empty'));
});
}
}
})(jQuery);
The code looks right to me but I am no javascript expert. Any ideas what I could be doing wrong?
Thanks.