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
          jQuery.validator.addMethod("validInputType", function(value, element, param) {
              return value !== '';
          }, jQuery.format('Field can not be empty'));

The code looks right to me but I am no javascript expert. Any ideas what I could be doing wrong?


  • Try closing Drupal.behaviors.dynamicTextfieldValidator with a semicolon.
    – adam_bear
    Jun 21 '13 at 19:50
  • Thanks for the suggestion, but it didn't work. I still get the same error.
    – user5013
    Jun 21 '13 at 22:44
  • Is validation loading after jquery? I've had problems with this module due to function clientside_validation_js_alter() not referencing $javascript or setting a group, which caused it to load before other scripts.
    – adam_bear
    Jun 21 '13 at 23:15
  • I see that jquery.validate.js is being loaded after all the jquery scripts. What I don't see is my validation script being loaded. I am using drupal_add_js() with the correct file path but I still don't see it in the list of scripts being loaded. Any ideas?
    – user5013
    Jun 24 '13 at 16:07
  • Where is the call to drupal_add_js being made? yourmodule_js_alter || yourtheme_js_alter || other?
    – adam_bear
    Jun 24 '13 at 19:27

Browse other questions tagged or ask your own question.