Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

card type through card number

function detectCardType(number) {
    var re = {
        electron: /^(4026|417500|4405|4508|4844|4913|4917)d+$/,
        maestro: /^(5018|5020|5038|5612|5893|6304|6759|6761|6762|6763|0604|6390)d+$/,
        dankort: /^(5019)d+$/,
        interpayment: /^(636)d+$/,
        unionpay: /^(62|88)d+$/,
        visa: /^4[0-9]{12}(?:[0-9]{3})?$/,
        mastercard: /^5[1-5][0-9]{14}$/,
        amex: /^3[47][0-9]{13}$/,
        diners: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
        discover: /^6(?:011|5[0-9]{2})[0-9]{12}$/,
        jcb: /^(?:2131|1800|35d{3})d{11}$/
    }

    for(var key in re) {
        if(re[key].test(number)) {
            return key
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: regex expression for email 
Javascript :: how to convert a string to a mathematical expression programmatically javascript 
Javascript :: js setattribute download 
Javascript :: download pdf javascript 
Javascript :: add countdown timer to javascript quiz 
Javascript :: how to manage logging using winston for production and development in node js "github" 
Javascript :: create express js project 
Javascript :: js import export 
Javascript :: local storage for chrome extension 
Javascript :: how to get css property of div after rendering in react js 
Javascript :: csrf javascript 
Javascript :: javascript ide 
Javascript :: nodejs heap usage 
Javascript :: kotlin jsonobject to class 
Javascript :: splice from array javascript to remove 
Javascript :: using express js response render parameter in ejs script tag as a variable in node js 
Javascript :: How to pass variables from js to html node 
Javascript :: filter array inside array of objects javascript 
Javascript :: how to check if the number inputed is number 
Javascript :: loop array of objects 
Javascript :: children array javascript 
Javascript :: two object combine together javascript 
Javascript :: Split string into words, without punctuation 
Javascript :: reactjs date display 
Javascript :: js array pop 
Javascript :: handling event in jsx 
Javascript :: pagination.js example codepen 
Javascript :: how to remove console.log from react native app 
Javascript :: js add to array 
Javascript :: jquery get table to object 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =