// You will need various ragex for difference card validation
// eg
function cardnumber(inputtxt)
{
var cardno = /^(?:4[0-9]{12}(?:[0-9]{3})?)$/;
if(inputtxt.value.match(cardno))
{
return true;
}
else
{
alert("Not a valid Visa credit card number!");
return false;
}
}
// Or you can use card-validator npm package
// npm i card-validator
var valid = require("card-validator");
var numberValidation = valid.number("4111");
if (!numberValidation.isPotentiallyValid) {
renderInvalidCardNumber();
}
if (numberValidation.card) {
console.log(numberValidation.card.type); // 'visa'
}