Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creditcard validation throws error only on mobile Safari #1767

Open
bradmurray opened this issue Apr 15, 2016 · 9 comments
Open

creditcard validation throws error only on mobile Safari #1767

bradmurray opened this issue Apr 15, 2016 · 9 comments

Comments

@bradmurray
Copy link

bradmurray commented Apr 15, 2016

Versions:

  • jquery 2.2.3
  • jquery-validate version 1.15.0
  • mobile Safari on iOS 9.3 (confirmed on both iPhone 5 and iPhone 6s+

This code works fine on all other tested browsers (desktop and mobile) but in mobile Safari when calling the .validate for the page I receive:

[Error] TypeError: undefined is not an object (evaluating 'a.validator.methods[d].call').  Exception occurred when checking element txtCreditCardNumber, check the 'creditcard' method.
    check (jquery.validate.min.js:4:11271)
    element (jquery.validate.min.js:4:7203)
    onfocusout (jquery.validate.min.js:4:3486)
    b (jquery.validate.min.js:4:5194)
    dispatch (jquery-2.2.3.min.js:3:7543)
    handle (jquery-2.2.3.min.js:3:5626)
    trigger (jquery-2.2.3.min.js:4:4842)
    simulate (jquery-2.2.3.min.js:4:5262)
    c (jquery-2.2.3.min.js:4:6025)

the error is reported as coming from jquery.validate.min.js:276

The rule for this field is simply:

{ required: true, creditcard: true }

My current workaround is to change the rule to:

{ required: true, digits: true, minlength: 12, maxlength: 16 }

when I detect an iOS device. This seems to work but is not ideal.

@staabm
Copy link
Member

staabm commented Apr 16, 2016

Could you provide a reduced jsfiddle which reproduces your issue?

@bradmurray
Copy link
Author

bradmurray commented Apr 16, 2016

I distilled it down as best as I could to this: https://jsfiddle.net/xt6yasLt/15/

In doing this I found that what seems to cause the problem is the max property of the input field. It works in most browsers, but mobile safari doesn't seem to like it. I have guessing that 9999999999999999 is overflowing in that browser.

@stale

This comment has been minimized.

@stale stale bot added the stale Used to mark stale issues label Jun 5, 2018
@stale stale bot closed this as completed Jun 12, 2018
@pirco
Copy link

pirco commented Oct 22, 2018

having the same issue. not only safari iOS but safari desktop (v12 on OS mojave)

@Arkni
Copy link
Member

Arkni commented Jan 19, 2019

Hi all,

Re-opening this issue as the bug still persist. I will try to fix the issue as soon as I got some free time, but if anyone is interested in fixing this issue and submit a proposal, please do. I'd be more than happy to walk you through the steps involved.

And, sorry about the closing of this issue by our bot.

@Arkni Arkni reopened this Jan 19, 2019
@Arkni Arkni added Type: Bug Additional Methods help wanted and removed stale Used to mark stale issues labels Jan 19, 2019
@carlos-mg89
Copy link

Something similar is happening to me, in Firefox 72.0.1 on Ubuntu 19.10 but with the minLength rule.

Exception occurred when checking element password, check the 'minLength' method. TypeError: "a.validator.methods[d] is undefined"

The error seems to happen only for fields with the minLength or maxLength restrictions.

This seems to be quite an important bug, to be honest. I'd be happy to try to fix this bug. Any guidance would be more than welcome @Arkni

@carlos-mg89
Copy link

I've tried with jQuery 3.1 and 3.4 with no luck. Perhaps that's the reason of the bug.

I'm using the jQuery migrate as well but it doesn't improve.

@carlos-mg89
Copy link

jQuery Core 2.2.4 doesn't help wither.

@carlos-mg89
Copy link

Alright, I've already figured out what was going on. This plugins works great with jQuery 3.4.1 and without the jQuery migration script.

Except when you use the minLength and maxLength restrictions. Then I saw issues when using the highlight / unhighlight JS options. If not using them, then it works normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants