Regular Expression Credit Card Validation Script

Regular Expression Credit Card Validation Script is use to validate credit card a number through regular expression.

Demo :



Type Credit Card Number :    

Example :

Just type a Credit Card Number at text box like this 123 and click check button in this incorrect credit card number so Is not a 16-digit number message will display otherwise type correct Credit Card Number like this 781238990124527 and click check button Is a valid 16-digit number message will display here.

Code :

Following code is use to Credit Card Validation Script if you need to copy and use to your website.


<?php
  function validateCCNum($str)
  {
    return preg_match("/^\d{16}$/" ,$str);
  }
  $CCNum = '12345678';
  echo validateCCNum($CCNum) ? "Is a valid 16-digit number" : "Is not a 16-digit number";
?>

In the above $CCNum variable is use to assign the Credit Card Number. In the validateCCNum() function is use to check the validate credit card number through regular expression.

Free Download Script :

If you need Regular Expression Credit Card Validation Script click and download from following link.

Download




Content