2

I'm using jQuery Validator on a form on my site. It is functioning properly, but every keystroke results in an error:

Uncaught TypeError: Object #<error> has no method 'call' 

I am implementing validation through classes on each field and all that is working properly - required fields, email fields, numbers, etc.. Here is my validate code:

 if(jQuery().validate) {
      //assign to global var for manual validation
      validator = $(".validated").validate({
           errorClass: "help-inline text-error",
           errorElement: "span",
           invalidHandler: function(e, validator) {
                var errors = validator.numberOfInvalids();
                if (errors) {
                     var message = errors == 1
                          ? 'Please fix the indicated field before saving this form.'
                          : 'Please fix the errors on the indicated fields before saving this form.';
                      $(".validation-message").text(message);
                      $(".validation-message").addClass('alert alert-error');
                } else {
                      $(".validation-message").removeClass('alert alert-error').text("");
                }
             },
           onkeyup: true,
           submitHandler: function(form) {
                $(".validation-message").removeClass('alert alert-error').text("");
                form.submit();
             },
           errorPlacement: function(error, element) {
                if(element.parent().hasClass('input-append')){
                     error.insertAfter( element.parent() );
                }else{
                     error.insertAfter(element);
                }
             }
      });
 }

Can anyone see what would trigger that error without impacting functionality?

Cheers!

3
  • 2
    The onkeyup option is what's causing this. Commented Mar 1, 2013 at 16:35
  • Yes.. that is what's causing it to happen on keystroke, but the error is still happening..... Commented Mar 1, 2013 at 16:46
  • Ah.. yes I see.. the true is not a valid value. Commented Mar 1, 2013 at 16:53

1 Answer 1

9

There is no true value for onkeyup option.

By default the field validation is enabled during keyup event. You need to use this option only in two scenarios

  1. To disable validation during keyup event, in that case set onkeyup: false
  2. To customize field validation during keyup

In your case you can just remove the option onkeyup.

Sign up to request clarification or add additional context in comments.

1 Comment

Ahh.. yes, thanks. I set it to false while testing, now I see that I was wrong to set it to true to re-enable it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.