mercredi 21 septembre 2016

Credit card numbers starts with 1 & 15 digits long

i have written following jquery/javascript function for validating a credit card which is 15 digit long & must start with digit1. so, how would i validate that the number will start with digit 1.

if ($("#ddlCreditCardType" + i).val() == 'VI') {
  if (!($("#txtCreditCardNo" + i).val().length == 16)) {
    $("#err" + i).html('Credit Card Number should be 16 digit');
    status = 0;
  } else if ($("#txtCreditCardNo" + i).val().substring(0, 3).toLowerCase() == "rnr") {
    $("#err" + i).html('');
    status = 1;
  } else if ($("#txtCreditCardNo" + i).val().substring(0, 1) != 4) {
    $("#err" + i).html('Invalid Credit Card Number');
    status = 0;
  } else {
    $("#err" + i).html('');
    status = 1;
  }

Aucun commentaire:

Enregistrer un commentaire