Epsilon47
Epsilon47

Reputation: 838

How to properly import jquery validation via npm

How do I properly import jquery validation via npm ?

(https://www.npmjs.com/package/jquery-validation). I tried to simply put: @import jquery-validation/dist/jquery.validate.min.js to my scripts but

I got some errors in my next scripts so I just downloaded the code and imported in this way:

<script src="{{ asset('js/jquery-validation.js') }}"></script>

I would, although, prefer the import from node_modules but I did not find any guide to do it properly.

Upvotes: 0

Views: 7090

Answers (3)

EL MAHDI Bouzkoura
EL MAHDI Bouzkoura

Reputation: 446

question is old but it my help someone. importing jquery-validation isn't enough for it to work. this is the full implementation :

import $ from "jquery";
import jqueryValidate from "jquery-validation";
window.$ = $; // u need to include jquery in your window

Upvotes: 0

maiakd
maiakd

Reputation: 160

I know this is old but importing it worked for me :


import jqueryValidate from "jquery-validation";

(don't forget to npm i jquery-validation first of course)

Upvotes: 0

dikuw
dikuw

Reputation: 1158

Put

const jquery-validation = require('jquery-validation');

at the top of your app.js

Upvotes: 1

Related Questions