jQuery validator - Cannot call method 'call' of undefined error - while adding validation dynamically

前端 未结 6 1676
失恋的感觉
失恋的感觉 2020-12-31 14:13

This is my code to update the jQuery validation dynamically. In document load i create the validation. This code is used to update the phone number validation dynamically. A

6条回答
  •  不知归路
    2020-12-31 14:21

    I had the same problem, but with a different cause. The same problem happens when I put a rule "require:true" instead of "required:true".

    This error happens when you specify in your rules a validation that has no corresponding method. Through debugging I found that the exception is showing I specified a rule "require" by the method name was "required". It attempts to access a method within a hashmap, and tries to .call() even if the method is not found, which results in an exception.

    If the plugin author simply threw a custom error in this case that stated "The rule 'require' has no method" it would be easier to debug & recognize the typo.

    This is also the same cause of the infamous problem with the plugin submitting even though fields are invalid. See & vote for my issue report - https://github.com/jzaefferer/jquery-validation/issues/1212

提交回复
热议问题