Jquery-validation: Document use of additional-methods via npm

Created on 9 May 2017  路  2Comments  路  Source: jquery-validation/jquery-validation

Subject of the issue

I'm getting this error when trying to validate phoneUS:

image

I'm guessing it's due to not having additional-methods.js included in my app. I have 'jquery-validation' installed via npm and have this line in my code:

import 'jquery-validation'

I expected the solution to be something like:

import 'jquery-validation'
import 'jquery-validation/additional-methods'

but that didn't work.

Your environment

  • version of jquery-validate: 1.16.0

Most helpful comment

It should be:

// Using ESM
import "jquery-validation/dist/additional-methods.js"

// Using commonjs
require("jquery-validation/dist/additional-methods.js")

All 2 comments

As a quick workaround you can directly import the file.
import '/node-modules/jquery-validation/dist/additional-methods'

Just make sure to have the right path. For me it was like that.
require('../../../node_modules/jquery-validation/dist/additional-methods.js');

It should be:

// Using ESM
import "jquery-validation/dist/additional-methods.js"

// Using commonjs
require("jquery-validation/dist/additional-methods.js")
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kodeo picture kodeo  路  7Comments

iamandycohen picture iamandycohen  路  5Comments

Bek81 picture Bek81  路  3Comments

harkinj picture harkinj  路  8Comments

eproffit picture eproffit  路  4Comments