Git Product home page Git Product logo

jquery-creditcardvalidator's People

Contributors

gabrieljoelc avatar geoffreylitt avatar mrkarad avatar paweldecowski avatar rafaellyra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-creditcardvalidator's Issues

is this library still active?

it was last updated 2 years ago, and many issues are pending, i want to use it in my project confused whether to use it or not?

Add examples of usage

To make development easier there should be some examples. That way contributors don’t have to write their own to test new features/bugfixes.

Bug Internet Explorer 7 (EcmaScript 3)

There is a bug in the 81:
--->> digit = _ref[n]; <<--

In Internet Explorer 7, as it uses EcmaScript 3, it is not possible to read string's chars as it were an array. The solution is just to use "charAt" method, so:
--->> digit = _ref.charAt(n); <<--

Regards

Add `valid` property to the `result`

Currently there are three properties which indicate results of three different aspects of validation:

  • card_type — whether the card prefix has been recognised (regardless of the below being valid or not)
  • luhn_valid — whether the Luhn checksum is valid
  • length_valid — whether the length of the card number is valid for the type of card

Having this breakdown is useful to provide the user the exact reason why the card number is invalid. For example:

  • Card type not recognised.
  • Card number appears to be invalid.
  • Card number length for Visa must be 16 characters.

However, in some cases all the developer needs to know is the combined result of validation, ie if all three validation tests were successful.

To indicate it, I propose adding a valid parameter which is set to true only if all validation tests have passed, and set to false otherwise.

The developer won’t have to check two properties anymore (two, because card_type doesn’t need to be checked — luhn_valid and length_valid are always false if card type is not recognised):

if (result.luhn_valid && result.length_valid) {
    // ...
}

Instead the developer will be able to do:

if (result.valid) {
    // ...
}

Add support for JCB cards

JCB is considered a major credit card brand in Asia. It'd be great if you could add support for it.

The regex rule for detecting JCB is:

^(?:2131|1800|35\d{3})\d{11}$

JCB cards beginning with 2131 or 1800 have 15 digits. JCB cards beginning with 35 have 16 digits.

Source: http://www.regular-expressions.info/creditcard.html

PS: This script hasn't been updated in 2 years .. are you still maintaining it?

Feature Request: event emissions

Since the functionality is mostly driven by events (input or keyup), it would make sense to emit events such as a creditcard.valid event that you could listen for.

This would also allow you to separate the <input> from the controller or event handler and pass context using event targets.

Fantastic work on this!

[enhancement] Add missing bower.json.

Hey, maintainer(s) of PawelDecowski/jQuery-CreditCardValidator!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library PawelDecowski/jQuery-CreditCardValidator is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "PawelDecowski/jQuery-CreditCardValidator",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Amex not working?

Hi,

As soon as I start to enter an amex card number, nothing happens. In this case, card starts with 37....

Differences between documentation and implementation

The documentation states that the object passed to the callback function contains card_type property which contains "one of the strings describing the card type" (or null). However, this is not the case. The card_type property refers to the matching object from the card_types array.

This doesn't seem a major problem, but either the documentation should be changed, or the implementation should be changed to return card_type.name (personally I think it would be better to change the implementation as there is likely to be little need for the pattern and valid_length properties which are currently also returned).

Amex icon

This great plugin misses the amex icon, it would be great if you add it.

Cheers

Masking

An option to automatically add the spaces to the card numbers to reflect the spacing on a credit card, i.e. Visa "4444 1234 1234 1234", AMEX "4747 123456 12345"

SOME VALID VISA & DINERS CLUB NUMBERS ARE MARKED AS INVALID

Visa: 4222222222222 *
Diners: 38555565010005 & 38520000023237

*Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.

Those numbers are valid and the validator will not consider them so.

Thanks.

setting up jquery-creditcardvalidator (I need an idiots guide)

Im a web developer. Im Not so competent in jquery or javascript.

I have a HTML form (below) to collect payment details. I want to validate the Card entered.

Is it possible for you guys to tell me how to embed the scripts and link to the form?

Is there any sample that is a html page with a sample form and the files included. So i can just copy and paste it in straight away. I want it exactly the way you have displayed it on your home page.

Hope you can help.

Thanks in advance.

Zohaib

HTML CODE

<form action="submit_card_details.php" method = "post">
    <input  type="text" name="nameOnCard" size="28">
    <input  type="text" name="cardNumber"  size="16">
    <input  type="text" name="expiry" size="5">
    <input  type="text" name="cvv" size="3">
</form>

Accepted card types

It is not possible to set a list of acceptable card types, if the card type not in the list card will be invalid.

Add the input to be send back with the event

Add the input to the event so you can reference it easily from within the function enclosure for the event:

    validate_number = function(inp, number) {
      var length_valid, luhn_valid;
      card_type = get_card_type(number);
      luhn_valid = false;
      length_valid = false;
      if (card_type != null) {
        luhn_valid = is_valid_luhn(number);
        length_valid = is_valid_length(number, card_type);
      }
      return callback(inp, {
        card_type: card_type,
        luhn_valid: luhn_valid,
        length_valid: length_valid
      });
    };
    validate = function() {
      var number;
      number = normalize($(this).val());
      return validate_number(this, number);
    };

Clean download JS error

Uncaught TypeError: Cannot read property 'replace' of undefined - line 188 jquery.creditCardValidator.js

I'm loading:
jquery-1.11.3.min.js
jquery-ui-1.11.4/jquery-ui.min.js

then loading:
jquery.creditCardValidator.js

Get an error on that basic setup.

AMEX card numbers not validating

I've tried several test AMEX numbers, both in my form, and the demo form on your site. None of them seem to validate. Here are a few test numbers I've tried. These test numbers are from various web sites offering numbers for testing. Other card test (VISA MasterCard, Discover) numbers work fine.
341111111111111
378282246310005
378734493671000
34343434343434
349615762874365

ie11 compatibility issue

ie11 - windows8
Method get_card_type returns always null, preventing to detect the card type

commenting the lines below seems to fix the problem

this.on('input.jccv', (function(_this) {
  return function() {
    $(_this).off('keyup.jccv');
    return callback.call(_this, validate());
  };
})(this));

A Mastercard number is evaluating to American Express

My customer says he tried twice to enter his Mastercard number, and the function kept choosing "AmEx" as his card type.

We did have the acceptable cc types restricted to the major four, so maybe the customers c.c. was some obscure type of Mastercard (like a diners card?) that didn't evaluate to Mastercard.

I dont have the full number, and also wouldn't be able to post it anyway but here is some info about it:

billingState: "IL"
exMonth: "1"
exYear: "2015"
ccNumber: "XXXX7338"
ccType: "American Express" (this is the part that he did not input. the system gave it wrongly to him).

How to call the trigger function in latest version

In older version i found some trigger function to check the card is valid or invalid

 $(this).trigger('creditcard.validation', validationResult);
      if (card_type && luhn_valid && length_valid) {
        $(this).trigger('valid.creditcard.validation', validationResult);
      } else {
        $(this).trigger('invalid.creditcard.validation', validationResult);
      }

i do not find this in latest version, i need this trigger in latest, how can i do it ?

Demo Amex Support

I'm trying to do something very much like your demo but for some reason when I attempt to add Amex support it typically displays as Discover.

Credit vs Debit cards

any plans to differentiate between the two - UK user here and it's needed

also I think Maestro no longer requires start date / issue number - here in the UK at least

Add new Mastercard range

Start from Oct 2016 Mastercard is introducing a new range of numbers with the following first 6 digits range, 222100-272099

please add it up

Include graphics for all card types

Please include those pretty graphics for all card types you handle and include in your sample CSS.

http://jquerycreditcardvalidator.com/card_logos.png

We would be able to pay $50 for this request if you could complete by 5/15/2013. Please email me for billing details. Also, could you please include an explicit license file in your source tree.

Two Valid VISA numbers don't work

These two VISA numbers are provided as Test card numbers with Authorize.net:

  • Visa Test Card: 4007000000027
  • Second Visa Test Card: 4012888818888

They're valid according to the PHP Luhn check code

function is_valid($number) {
  $cardNumber = strrev($number);
  $numSum = 0;

  for ($i=0; $i<strlen($cardNumber); $i++) {
    $currentNum = substr($cardNumber, $i, 1);

    // Double every second digit
    if ($i % 2 == 1) {
      $currentNum *= 2;
    }

    // Add digits of 2-digit numbers together
    if ($currentNum > 9) {
      $firstNum = $currentNum % 10;
      $secondNum = ($currentNum - $firstNum) / 10;
      $currentNum = $firstNum + $secondNum;
    }

    $numSum += $currentNum;
  }

  // If the total has no remainder it's OK
  return ($numSum % 10 == 0);
}

but not when you try them on http://jquerycreditcardvalidator.com

Accept parameter function / jQuery validator tie-in

I tried writing the basic option myself as well as used the code from your demo page but I cannot get the accept parameter to work.

On your demo page, you specified not to accept Diners, so I figured that would be a good one to try. If you try the number 30569309025904 (taken from http://www.validcreditcardnumber.com), there is no front-end feedback that it is not accepted. How would I be able to do this?

Also, I'm using jQuery Validator to validate the rest of my form, is there a way to tie your plugin in? I need to only allow VISA and Mastercard on my form.

Thanks!

Elo support

Any idea of having support for ELO Credit Card?

This shouldn't be a jquery plugin

Hi. Nice work on the library. But this really shouldn't be a jquery plugin.

The library should expose a function such as validate(), then let users bind that to the input changes and do whatever with it. There's really no need to have to require jquery to use it.

Change request: The BIN range for new mastercard

We have got an email from our payment gateway provider saying there is a change in master card BIN, mastercards will also start with "2" from now onwards.
the current validator does not support this :(

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.