Uncaught TypeError: Cannot read property 'addMethod' of undefined

for me it was fixed when i put $.validator.addMethod method out of $(document).ready(function(){ !
and there was no need to use noConflict() method...
if you use Webpack(or Laravel mix like me) check the order of compiled js which sometimes it put validator before jquery and that causes this error


Add jquery.validate.js file and jquery.min.js if you have not included and then write your code of js for add 'addMethod' method.


Your error:

Uncaught TypeError: Cannot read property 'addMethod' of undefined

It simply means that JavaScript cannot find the addMethod method, which is built into the jQuery Validate plugin. jQuery or jQuery Validate was not included properly... the file(s) cannot be found or jQuery is broken...

Your head section is a mess with multiple versions of jQuery and .noConflict() applied inconsistently.

Notice how you've define .noConflict() just after this particular version of jQuery is included?

<!--Validation  -->
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.js"></script> 
....
<script type="text/javascript">
    var jQuery_1_7_0 = $.noConflict(true);  // <- this
</script>

So for the validation section, the name jQuery_1_7_0 must replace every instance $ just within your validation code.

jQuery_1_7_0(document).ready(function () {

    jQuery_1_7_0.validator.addMethod( ....

I've only pointed out one example. You've also included a version of jQuery without .noConflict() just above your validation section.

These multiple versions of jQuery need to be resolved, either by removing the duplicates and leaving one version or by properly using .noConflict() after each version is included.

IMO, it's best to only use one version of jQuery.

Documentation: Using jQuery .noConflict()