Jquery validation plugin - TypeError: $(…).validate is not a function

后端 未结 8 1127
不知归路
不知归路 2020-12-01 08:45

My script throw errors:

TypeError: jQuery.validator is undefined additional-methods.js:20 TypeError: $(...).validate is not a function index.php:115

8条回答
  •  醉话见心
    2020-12-01 09:45

    for me, the problem was from require('jquery-validation') i added in the begging of that js file which Validate method used which is necessary as an npm module

    unfortunately, when web pack compiles the js files, they aren't in order, so that the validate method is before defining it! and the error comes

    so better to use another js file for compiling this library or use local validate method file or even using CDN but in all cases make sure you attached jquery before

提交回复
热议问题